Setting statusbarStyle (deprecated in iOS 9.0)

后端 未结 6 1522
北恋
北恋 2020-12-13 09:13

Just downloaded the new xCode 10.0 and saw that the old statusBarStyle has been deprecated since iOS 9.0.

Warning: Setter for \'statusBarStyle\

6条回答
  •  情话喂你
    2020-12-13 09:40

    Set your darkMode variable using the same code you have now, then use it in the computed variable that the system is expecting:

    var darkMode = false
    override var preferredStatusBarStyle : UIStatusBarStyle {
        return darkMode ? .default : .lightContent
    }
    

    Depending on the context you may need to force a refresh of the screen for it to take effect. You would do that with the following call:

    setNeedsStatusBarAppearanceUpdate()
    

提交回复
热议问题