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.leftBarButton
This code changes the arrow color
self.navigationController.navigationBar.tintColor = UIColor.whiteColor();
If this does not work, use the code below:
self.navigationBar.barStyle = UIBarStyle.Black
self.navigationBar.tintColor = UIColor.whiteColor()
Swift 3 Notes
UIColor.whiteColor()
and similar have been simplified to UIColor.white
Also, many previously implicit optionals have been changed to explicit, so you might need:
self.navigationController?.navigationBar =
You have one choice hide your back button and make it with your self. Then set its color.
I did that:
self.navigationItem.setHidesBackButton(true, animated: true)
let backbtn = UIBarButtonItem(title: "Back", style:UIBarButtonItemStyle.Plain, target: self, action: "backTapped:")
self.navigationItem.leftBarButtonItem = backbtn
self.navigationItem.leftBarButtonItem?.tintColor = UIColor.grayColor()
It will be solved with this line in -(void)viewDidLoad:
self.navigationItem.backBarButtonItem.tintColor = UIColor.whiteColor;
Swift 3
The most upvoted answer is not correct for Swift 3.
The correct code to change color is:
self.navigationController?.navigationBar.tintColor = UIColor.white
If you want to change color, change UIColor.white above to the desired color
Add following code to didFinishLaunchingWithOptions function in AppDelegate.swift
var navigationBarAppearace = UINavigationBar.appearance()
navigationBarAppearace.tintColor = uicolorFromHex(0xffffff) // White color
navigationBarAppearace.barTintColor = uicolorFromHex(0x034517) // Green shade
// change navigation item title color
navigationBarAppearace.titleTextAttributes =[NSForegroundColorAttributeName:UIColor.whiteColor()]
You can change the global tint color in your storyboard by clicking on an empty space on the board and select in the right toolbar "Show the file inspector", and you will see in the bottom of the toolbar the "Global Tint" option.