Can't Hide Status Bar-Swift 3,

Can't Hide Status Bar—Swift 3,

We need to override the property itself on Swift 3 (this is new in Xcode 8 Beta 4):

override var prefersStatusBarHidden: Bool {  
return true
}

updated Swift 5+

override var prefersStatusBarHidden: Bool { true }

for another example also you can get here and here

For more on what this change is and why it's necessary, see Matt's great answer on this.

Xcode 8.2: Swift3- how to hide status bar?

You can Approach this in two ways

Option 1.Try this in didFinishLaunchingWithOptions Method

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

UIApplication.shared.isStatusBarHidden = true

return true
}

Option 2. overrideprefersStatusBarHidden function in your UIViewController

override var prefersStatusBarHidden : Bool {
return true
}

Note: you call override func prefersStatusBarHidden it should be override var prefersStatusBarHidden

Hide Status Bar in iOS 13

Step 1 :- add permission

Sample Image

Step 2 :- add the below code in desired view controller to hide the status bar .

override var prefersStatusBarHidden: Bool {
return true
}

NOTE :- if you don't set constrain properly after the hidden true / false you will have design issues , so take care about it ...:)

Cannot hide status bar in a specific view controller in iOS 11, Swift 4

In view controller where you want to hide the status bar,

In the viewWillAppear method, UIApplication.shared.isStatusBarHidden = true,

In the viewWillDisAppear method, UIApplication.shared.isStatusBarHidden = false

iOS11 - Can't hide status bar

I ran into the same thing using STPopUpPreview. I had to set modalPresentationCapturesStatusBarAppearance = true on my preview view controller. Good luck!

Hide status bar on iOS Swift

What you can do is to show and hide in Appear and Disappear

   override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.isNavigationBarHidden = true
}

override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
navigationController?.isNavigationBarHidden = false
}

How do I hide the status bar in a Swift iOS app?

You really should implement prefersStatusBarHidden on your view controller(s):

Swift 3 and later

override var prefersStatusBarHidden: Bool {
return true
}


Related Topics



Leave a reply



Submit