Andrea Garau
Andrea Garau

Reputation: 65

Hide Status Bar in iOS 13

Hiding Status Bar using the usual way doesn't work because the method is deprecated. enter image description here

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

Answers (2)

ghostK9
ghostK9

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

Shivam Parmar
Shivam Parmar

Reputation: 1570

Step 1 :- add permission

enter image description here

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

Related Questions