How to change status bar style – iOS 12

Swift 4+, iOS 12+

View controller-based status bar appearance now needs to be set to YES in info.plist since UIKit no longer wants us to edit status bar style through UIApplication.shared—status bar style is now view-controller based.

Then if you want the change to be applied at app level, simply override preferredStatusBarStyle in the appropriate container view controller (ideally the root)…

override var preferredStatusBarStyle: UIStatusBarStyle {
    return .lightContent
}

…and this will propagate to all view controllers underneath it. And if you want to edit status bar style per view controller, apply this override per view controller.

If status bar style ever changes during runtime, then you need to call setNeedsStatusBarAppearanceUpdate() (from anywhere in the container/root view controller or that specific view controller), otherwise it isn’t needed.

Leave a Comment