setStatusBarHidden is deprecated in iOS 9.0

后端 未结 6 2161
梦毁少年i
梦毁少年i 2020-12-14 00:00

I am upgrading my code from iOS 8 to iOS 9. I have a code snippet in my program [[UIApplication applicationName] setStatusBarHidden:YES];.

I am getting

6条回答
  •  忘掉有多难
    2020-12-14 00:40

    prefersStatusBarHidden is available from iOS 7+.

    Use this in Your UIViewController class

       var isHidden = true{
            didSet{
                self.setNeedsStatusBarAppearanceUpdate()
            }
        }
        override var prefersStatusBarHidden: Bool {
            return isHidden
        }
    

    If you change the return value for this method, call the setNeedsStatusBarAppearanceUpdate() method. To specify that a child view controller should control preferred status bar hidden/unhidden state, implement the childViewControllerForStatusBarHidden method.

提交回复
热议问题