iOS 5:UIBarButtonSystemItem的文本颜色添加

时间:2012-07-15 11:16:44

标签: objective-c

我可以使用此代码段(iOS 5 +)更改 UIBarButtonItem 的文本颜色:

NSMutableDictionary *attributes = [NSMutableDictionary dictionary];
[attributes setValue:[UIColor blackColor] forKey:UITextAttributeTextColor];   
[[UIBarButtonItem appearance] setTitleTextAttributes:attributes forState:UIControlStateNormal];

不幸的是,这不会影响 UIBarButtonSystemItemAdd

有没有办法更改 UIBarButtonSystemItemAdd 的文字颜色?

2 个答案:

答案 0 :(得分:4)

使用setTintColor。例如:

[downloadButtonItem setTintColor:[UIColor colorWithRed:247.0/255.0 green:247.0/255.0 blue:247.0/255.0 alpha:1.0]];

答案 1 :(得分:3)

我知道无法实现这一点 - 系统UIBarButtonItem实例使用图像而不是文本,因此无法通过更改标题文本颜色来更改颜色。您很可能必须创建自己的栏按钮项目。