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

后端 未结 15 1271
挽巷
挽巷 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:51

    Use this code:

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
    
        UIApplication.shared.isStatusBarHidden = true
    }
    

    if this code doesn't work, you need to add this key in the info.plist

    View controller-based status bar appearance - NO

提交回复
热议问题