有没有简单的方法来改变UIBarButtonItem的文本颜色,而不使用图像? [英] Is there an easy way to change the text color of a UIBarButtonItem without using an image?
问题描述
有没有简单的方法来改变UIBarButtonItem的文本颜色,而不使用UIImage作为背景?
Is there an easy way to change the text color of a UIBarButtonItem without using an UIImage as the background?
默认情况下,文本总是白色的。
By default the text is always white. I'd like to make it black.
推荐答案
您的问题的直接答案是否定的。
The direct answer to your question is no.
您不能通过设置其中一个属性来简单地更改 UIBarButtonItem
的颜色。您可以设置 UIToolBar
或 UINavigationBar
的 tintColor
包含 UIBarButtonItem
s,但也会影响工具栏本身的颜色,并且不提供太多的自定义。
You can't simply change the color of a UIBarButtonItem
by setting one of its properties. You can set the tintColor
property of the UIToolBar
or UINavigationBar
that contains the UIBarButtonItem
s, but that also affects the color of the toolbar itself and doesn't offer too much customization.
如果这不适合你,其他答案建议的自定义视图是一个好主意。
If that doesn't work for you, a custom view as the other answers suggest is a fine idea.
祝你好运!
这篇关于有没有简单的方法来改变UIBarButtonItem的文本颜色,而不使用图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!