3

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

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

不幸的是,这不会影响UIBarButtonSystemItemAdd

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

4

2 回答 2

4

使用 setTintColor。例如:

[downloadButtonItem setTintColor:[UIColor colorWithRed:247.0/255.0 green:247.0/255.0 blue:247.0/255.0 alpha:1.0]];
于 2013-10-13T14:10:59.813 回答
3

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

于 2012-07-15T12:10:14.670 回答