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?
In Swift 4, you can take care of this issue using:
In Swift3, To set the Back button to
red
.Add following code to didFinishLaunchingWithOptions function in AppDelegate.swift
Use this code in
AppDelegate
class, inside ofdidFinishLaunchingWithOptions
.Lets try this code:
Not sure why nobody has mentioned this...but I was doing exactly what you were doing in my
viewDidLoad
...and it wasn't working. Then I placed my code intoviewWillAppear
and it all worked.The above solution is to change a single barbuttonItem. If you want to change the color for every navigationBar in your code then follow this answer.
Basically changing onto the class itself using
appearance()
is like making a global change on all instances of that view in your app. For more see here