preferredStatusBarStyle not respecting on iOS 13

前端 未结 2 1522
独厮守ぢ
独厮守ぢ 2021-01-02 12:29

I\'m working in my simulator on a single view app with a dark background. It\'s a UIViewController wrapped in a UINavigationController.

In my view controller I have

相关标签:
2条回答
  • 2021-01-02 12:53

    The correct answer referenced by @matt is navigationController?.navigationBar.barStyle = .lightContent in viewDidLoad.

    0 讨论(0)
  • 2021-01-02 13:00

    I recently ran into this problem and these extensions seemed to fix the issue.

    extension UITabBarController {
        open override var childForStatusBarStyle: UIViewController? {
            return selectedViewController?.childForStatusBarStyle ?? selectedViewController
        }
    }
    
    extension UINavigationController {
        open override var childForStatusBarStyle: UIViewController? {
            return topViewController?.childForStatusBarStyle ?? topViewController
        }
    }
    

    I just put them into a file called UIViewController+StatusBar.swift and included it in the project.

    0 讨论(0)
提交回复
热议问题