UIStatusBarStyle not working in Swift UIStatusBarStyle not working in Swift ios ios

UIStatusBarStyle not working in Swift


You have two options.

If you want to continue manually setting the style of the status bar, continue doing what you're doing, but you'll need to add the following key to your info.plist file with a value of NO.

View controller-based status bar appearance

Or, if you want to continue to use view controller based status bar appearance, instead of setting the application's statusBarStyle, override the preferredStatusBarStyle property in each view controller for which you'd like to specify a status bar style.

Swift 3

override var preferredStatusBarStyle: UIStatusBarStyle {    return .lightContent}

Swift 2

override func preferredStatusBarStyle() -> UIStatusBarStyle {    return UIStatusBarStyle.LightContent}


Swift 3.0

in AppDelegate.swift didFinishLaunchingWithOptions

UIApplication.shared.statusBarStyle = .lightContent

Info.plist

View controller-based status bar appearance -> NO

Swift 2.2

in AppDelegate.swift didFinishLaunchingWithOptions

UIApplication.sharedApplication().statusBarStyle = .LightContent

Info.plist

View controller-based status bar appearance -> NO


You have to set the:

navigationController.navigationBar.barStyle = .black

and the text will appear in white