The background text in the status bar is still black. How do I change the color to white?
// io8, swift, Xcode 6.0.1
override func viewDidLoad() {
super.viewDidLoad()
self.navigationController?.navigationBar.barTintColor = UIColor.blackColor()
self.navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.orangeColor()]
}
To do this job in storyboard (Interface Builder Inspector)
With help of
IBDesignable
, we can add more options to Interface Builder Inspector forUINavigationController
and tweak them on storyboard. First, add the following code to your project.Then simply set the attributes for UINavigationController on storyboard.
Swift 4.1
Add a func to viewDidLoad
In the
setup()
function add:In Swift 3 this works:
If you want to set the tint color and bar color for the entire app, the following code can be added to AppDelegate.swift in
Navigation barTintColor and tintColor is set
Swift 4.2 version of Albert's answer-
In
AppDelegate.swift
, inapplication(_:didFinishLaunchingWithOptions:)
I put the following:For
titleTextAttributes
, the docs say: