I'm trying to programatically set the tintColor
for UIBarButtonItems
throughout my project. I'm calling:
[UIBarButtonItem appearance]
However, after looking at Apple's documentation here: http://developer.apple.com/library/ios/#documentation/uikit/reference/UIBarButtonItem_Class/Reference/Reference.html
I found no such properties for setting the tintColor
. The closest related methods I could find were:
setBackgroundImage:forState:barMetrics:
setBackgroundImage:forState:style:barMetrics:
However, both of these methods are for setting an actual background image. Is it not possible to simply set the button's tintColor
via UIAppearance
?
Maybe I dont understand the question correctly. But if you look in the link that you've posted, under Tasks -> Customizing Appearance, there's a property called tintColor.
You just have to set that property to the desired color
[[UIBarButtonItem appearance] setTintColor:[UIColor redColor]];
Is this not working for you?
As per the UIAppearance
Protocol, you can set the tintColor
as below :
To customize the appearances for instances of a class when contained within an instance of a container class, or instances in a hierarchy, you use
appearanceWhenContainedIn:
to get the appearance proxy for the class
[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil]
setTintColor:myNavBarColor];
This is mentioned here , if that's what you are looking for.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With