Search code examples
iosswift3uistatusbar

Set StatusBarStyle in Swift 3


I have set the ViewController-Based Status Bar Appearance to true in info.plist file.

in my ViewController, I set

override var preferredStatusBarStyle: UIStatusBarStyle {
    return .lightContent;
}

But my status bar is still black. Any ideas?


Solution

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

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