Preferred status bar style of view controller is ignored when in navigation controller
When you're in a navigation controller that will not get called. The navigation controller's preferredStatusBarStyle will be called. Try this along with your code:
extension UINavigationController {
open override var preferredStatusBarStyle: UIStatusBarStyle {
return topViewController?.preferredStatusBarStyle ?? .default
}
}
There is a solution that is a bit more concise (and recommended by Apple):
extension UINavigationController {
override open var childForStatusBarStyle: UIViewController? {
return topViewController
}
}