2012-07-15 51 views
3

我能够更改使用此代码段(iOS 5以上)的的UIBarButtonItem文本颜色:的iOS 5:文本颜色UIBarButtonSystemItemAdd

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

不幸的是,这并不影响UIBarButtonSystemItemAdd

有没有办法改变的文本颜色UIBarButtonSystemItemAdd

+1

不是真的 - 系统栏按钮项目是由图像组成 - 按钮中的“+”是PNG而不是字符串。 – 2012-07-15 11:23:03

+0

好的,我明白了。感谢您的回答。我想我会通过使用带有加号的自定义栏按钮项作为字符串来解决此问题。也许你想添加你的评论作为这个问题的答案,所以我可以标记问题解决? – Patrick 2012-07-15 11:49:43

回答

3

我知道没有办法做到这一点 - 系统UIBarButtonItem实例使用图像而不是文本,所以改变它们的颜色不能通过改变它们的标题文本颜色来完成。您很可能必须创建您自己的酒吧按钮项目。

4

使用setTintColor。例如:

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

只是我需要的“解决方法”。完美解决了我的问题。 – Fluffhead 2014-11-30 21:52:20