我想把颜色改成红色。
最佳答案
我找到了一种更简单的方法来改变标题的颜色: iOS7:
UIBarButtonItem *button =
[[UIBarButtonItem alloc] initWithTitle:@"Title"
style:UIBarButtonItemStyleBordered
target:nil
action:nil];
[button setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor redColor], NSForegroundColorAttributeName,nil]
forState:UIControlStateNormal];
和之前的 iOS7:
UIBarButtonItem *button =
[[UIBarButtonItem alloc] initWithTitle:@"Title"
style:UIBarButtonItemStyleBordered
target:nil
action:nil];
[button setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor redColor], UITextAttributeTextColor,nil]
forState:UIControlStateNormal];
关于iphone - 如何更改 UIBarButton 项的字体颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3314035/