How to change status bar style - iOS 12

前端 未结 6 1789
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-29 04:04

I need to update status bar style on every view controller based on the background color (what UINavigationController is doing automatically).

Have trie

6条回答
  •  感情败类
    2020-12-29 04:31

    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).

提交回复
热议问题