After implementing a UIViewController
, it seems that the status bar content colour doesn't change (still remains black) for some reason. How can it be changed to the 'light' mode (white colour) programatically only using Swift 4.0 for just this specific UIViewController
? Not the whole application.
ViewController.swift class
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = UIColor.blue
self.title = "Hello World"
self.navigationController?.navigationBar.barTintColor = UIColor.gray
self.navigationController?.navigationBar.prefersLargeTitles = true
self.navigationController?.navigationItem.largeTitleDisplayMode = .automatic
self.navigationController?.navigationBar.largeTitleTextAttributes = [
NSAttributedStringKey.foregroundColor: UIColor.white,
NSAttributedStringKey.font : UIFont.preferredFont(forTextStyle: .largeTitle)
]
}
override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}
}
jake.lange's suggestion