How to hide status bar of a single view controller in iOS 9?

后端 未结 15 1237
挽巷
挽巷 2020-12-13 06:15

In a ViewController, which I presented modally, I did this:

override func prefersStatusBarHidden() -> Bool {
    return true
}

This used

15条回答
  •  失恋的感觉
    2020-12-13 06:46

    For Swift 3 & Swift 4 it has changed to overriding a variable like this:

    override var prefersStatusBarHidden: Bool {
      return true
    }
    

    If you want to "Update" the state once the view controller is already being displayed, you will need to call:

    setNeedsStatusBarAppearanceUpdate()
    

    Please refer to the documentation.

提交回复
热议问题