John Ramos John Ramos - 1 year ago 1241
Swift Question

Can't Hide Status Bar—Swift 3,

I usually hide the status bar with

override func prefersStatusBarHidden() -> Bool {
return true

but Xcode is giving me an error, saying "Method does not override anything from its superclass".

If I delete the
, Xcode gives a different error: "Method 'prefersStatusBarHidden()' with Objective-C selector 'prefersStatusBarHidden' conflicts with getter for 'prefersStatusBarHidden' from superclass 'UIViewController' with the same Objective-C selector"

I also have "Hide Status Bar" checked in my Target's general settings:

enter image description here

but the status bar still shows up.

I found this method in another Stack Overflow answer

UIApplication.shared.setStatusBarHidden(true, with: .none)

but that doesn't hide the status bar either.

In Xcode 8 Beta 1, I used the first and second methods, which worked to hide the status bar (the first method did not return an error). What can I do now to hide the status bar, with Xcode 8 Beta 4?

Edit: The status bar shows up on Simulator devices and physical devices, all running iOS 10.

Answer Source

you need to override the property


override var prefersStatusBarHidden: Bool {  
  get {  
      return true