I am trying to change the color of the Settings button to white, but can't get it to change.
I've tried both of these:
navigationItem.leftBarButtonItem?.tintColor = UIColor.whiteColor()
navigationItem.backBarButtonItem?.tintColor = UIColor.whiteColor()
but no change, it still looks like this:
How do I make that button white?
This code changes the arrow color
If this does not work, use the code below:
Swift 3 Notes
UIColor.whiteColor()
and similar have been simplified toUIColor.white
Also, many previously implicit optionals have been changed to explicit, so you might need:
Swift 3
in swift 2.0 use
You have one choice hide your back button and make it with your self. Then set its color.
I did that:
This works for me, iOS 9.0+
All the answers setting
UINavigationBar.appearance().tintColor
conflict with Apple's documentation inUIAppearance.h
.In Xcode, you need to command-click on each property you want to use with appearance proxy to inspect the header file and make sure the property is annotated with
UI_APPEARANCE_SELECTOR
.So the correct way to color the navigation bar purple and the title and buttons white throughout the app via the appearance proxy is:
Note that
UIBarButtonItem
is not a subclass ofUIView
but ratherNSObject
. So itstintColor
property is not the inheritedtintColor
fromUIView
.Unfortunately,
UIBarButtonItem.tintColor
is not annotated withUI_APPEARANCE_SELECTOR
– but that seems to me a documentation bug. The response from Apple Engineering in this radar states it is supported.