Search code examples
iosswiftuiviewcontrollerstatusbar

prefersStatusBarHidden issue in iOS 13


Hi everyone I'm trying to hide my statusBar in a View Controller but it doesn't seem to work .. I used the function:


 override var prefersStatusBarHidden: Bool {
         return true
    }

I also set the View controller-based status bar appearance in the plist file to YES

My status bar doesn't want to hide ... where am I doing wrong?


Solution

  • It looks like you're trying to specifically hide the status bar in a single ViewController.

    In order to do that, you need have the following in that ViewController

    self.modalPresentationCapturesStatusBarAppearance = true

    override var prefersStatusBarHidden: Bool {
          return true
    }
    

    I also added View controller-based status bar appearance in my .plist and set it to YES.

    Tested on the latest iOS 13.