I working on a huge app loads of view controllers, the app currently sets in status bar style in the plist using:
Status bar style = UIStatusBarStyleLightContent
View controller-based status bar appearance = NO
New features require me to have some status bars in the dark default style.
So to summarize I need all the app with a default .lightContent and about 10VCs with an override to .default/dark
To start with I need to set the plist to:
View controller-based status bar appearance = YES
but once I do this many of the status bars in the app change to the .default / dark style.
I can change this style in every VC using:
override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}
but in an app this big, this would be impractical.
I've tried quite a few extensions to override behavior, but since these are instance methods they can't be overriden like this:
extension UIViewController
{
override open var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}
}
You can use this extension:
extension UINavigationController {
override open var preferredStatusBarStyle : UIStatusBarStyle {
return topViewController?.preferredStatusBarStyle ?? .default
}
}
But it only works on VC's in NavControllers and you need to set every single rootVC to .lightContent