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()]
}
//In Swift 4
Swift 4
I like Alex's answer. If you want something quick to try out in a
ViewController
make sure you useTo change the color universally, this code should sit in the
NavigationController
'sviewDidLoad
function:To change it per
ViewController
you would have to reference theNavigationController
from theViewController
and write similar lines in thatViewController
'sviewWillAppear
function.To work in objective-c I have to put the following lines in
viewWillAppear
in my CustomViewController.For Swift2.x this works:
For Swift3.x this works:
In Swift 4.1 and Xcode 9.4.1