我试图在整个项目中以编程方式为 UIBarButtonItems
设置 tintColor
。我在打电话:
[UIBarButtonItem 外观]
但是,在查看 Apple 的文档后: http://developer.apple.com/library/ios/#documentation/uikit/reference/UIBarButtonItem_Class/Reference/Reference.html
我没有找到用于设置 tintColor
的此类属性。我能找到的最接近的相关方法是:
setBackgroundImage:forState:barMetrics:
setBackgroundImage:forState:style:barMetrics:
但是,这两种方法都是为了设置实际的背景图像。难道不能通过 UIAppearance
简单地设置按钮的 tintColor
吗?
最佳答案
也许我没有正确理解这个问题。但是如果您查看您发布的链接,在任务 -> 自定义外观下,有一个名为 tintColor 的属性。
您只需将该属性设置为所需的颜色
[[UIBarButtonItem appearance] setTintColor:[UIColor redColor]];
这对你不起作用吗?
关于ios - 如何通过外观协议(protocol)设置 UIBarButtonItem 的 tintColor?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14862991/