NavigationBar bar, tint, and title text color in iOS 8 NavigationBar bar, tint, and title text color in iOS 8 ios ios

NavigationBar bar, tint, and title text color in iOS 8


In AppDelegate.swift, in application(_:didFinishLaunchingWithOptions:) I put the following:

UINavigationBar.appearance().barTintColor = UIColor(red: 234.0/255.0, green: 46.0/255.0, blue: 73.0/255.0, alpha: 1.0)UINavigationBar.appearance().tintColor = UIColor.whiteUINavigationBar.appearance().titleTextAttributes = [NSAttributedString.Key.foregroundColor : UIColor.white]

(For Swift 4 or earlier use NSAttributedStringKey instead of NSAttributedString.Key)

For titleTextAttributes, the docs say:

You can specify the font, text color, text shadow color, and text shadow offset for the title in the text attributes dictionary


I like Alex's answer. If you want something quick to try out in a ViewController make sure you use

viewWillAppear()override func viewWillAppear(animated: Bool) {    super.viewWillAppear(animated)    var nav = self.navigationController?.navigationBar    nav?.barStyle = UIBarStyle.Black    nav?.tintColor = UIColor.white    nav?.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.orange]    //nav?.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.orange] // swift 4.2}

enter image description here


To change the color universally, this code should sit in the NavigationController's viewDidLoad function:

class NavigationController: UINavigationController, UIViewControllerTransitioningDelegate {    override func viewDidLoad() {        super.viewDidLoad()        // Status bar white font        self.navigationBar.barStyle = UIBarStyle.Black        self.navigationBar.tintColor = UIColor.whiteColor()    }}

To change it per ViewController you would have to reference the NavigationController from the ViewController and write similar lines in that ViewController's viewWillAppear function.