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. override
prefersStatusBarHidden
function in yourUIViewController
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
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
Xcode - Bundle Format Unrecognized, Invalid, or Unsuitable
Swiftui Datepicker Binding Optional Date, Valid Nil
How to Disable/Enable the Sleep Mode Programmatically in iOS
Since Xcode 8 and iOS10, Views Are Not Sized Properly on Viewdidlayoutsubviews
iOS 5 JSON Parsing Results in Cocoa Error 3840
How to Lookup a String Constant at Runtime in Objective-C
Moving the Cursor to the Beginning of Uitextfield
Nsxmlparser: Unexpected Result with Non-Ascii Characters
Exc_Bad_Instruction When Passing Uicollectionview Cell Data to Different Viewcontroller
Xcode Simulator: How to Remove Older Unneeded Devices
How to Add Line Break for Uilabel
How to Attach Debugger to iOS App After Launch
Check If Uicolor Is Dark or Bright
Offscreen Uitableviewcells (For Size Calculations) Not Respecting Size Class
Unwind Segue from Navigation Back Button in Swift