I need to update status bar style on every view controller based on the background color (what UINavigationController is doing automatically).
Have tried all the options described on stackoverflow (View controller-based status bar appearance in info.plist set to YES), but none worked for me.
I am using Xcode 10 beta 6 and Swift 4.2, targeting iOS 12.
解决方案
Set View controller-based status bar appearance to NO in the info.plist and override preferredStatusBarStyle in each view controller like so:
override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}
And call setNeedsStatusBarAppearanceUpdate() in your view controller (in viewDidLoad() for example).