Reputation: 65
Hiding Status Bar using the usual way doesn't work because the method is deprecated.
The status bar has to be hidden in one view controller, but not all of them. How can I hide/show it programmatically?
Upvotes: 2
Views: 3598
Reputation: 51
just adding to the accepted answer, if your controller is embedded in a stack like how it was for me then you need an extra piece of code as well and be sure to provide this in/before the controller loads.
extension UINavigationController {
open override var prefersStatusBarHidden: Bool {
return topViewController?.prefersStatusBarHidden ?? true
}
}
then call this where you want to update
setNeedsStatusBarAppearanceUpdate()
Upvotes: 3
Reputation: 1570
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 ...:)
Upvotes: 4