2

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?

Andrea Garau
  • 69
  • 2
  • 5
  • 1
    Does this answer your question? [How do I hide the status bar in a Swift iOS app?](https://stackoverflow.com/questions/24236912/how-do-i-hide-the-status-bar-in-a-swift-ios-app) – kkiermasz Dec 14 '19 at 11:13
  • Look at this [link](https://discuss.cocos2d-x.org/t/how-to-hide-status-bar-in-ios13-in-cocos-2dx/48026) – Dhaval Raval Dec 14 '19 at 11:17
  • you also need to go to project->General->Status Bar Style set it to requires fullscreen and hidestatus bar – Dhaval Raval Dec 14 '19 at 11:17

2 Answers2

4

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 ...:)

Shivam Parmar
  • 1,520
  • 11
  • 27
  • 1
    is anyone found solution for this ios 13 status bar hide. I still facing this error please help me to rectify this error. – vijay Jul 03 '20 at 15:39
3

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()
ghostK9
  • 51
  • 3