Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide status bar of a single view controller in iOS 9?

Tags:

ios

swift

In a ViewController, which I presented modally, I did this:

override func prefersStatusBarHidden() -> Bool {     return true } 

This used to work, but it no longer works. What's the best way to hide the status bar only for this view controller?

like image 525
TIMEX Avatar asked Jan 27 '16 03:01

TIMEX


People also ask

How do I hide the status bar on my Iphone?

To completely hide it on the home screen, open up an app, such as Settings, and wait about three to four seconds. Press the home button again, and the status bar will be completely gone.

How do I hide my status bar on storyboard?

step 1 : in your frameWork-Info. plst' file, add the key 'View controller-based status bar appearance' and set it to 'NO'.


1 Answers

For Swift 3 & Swift 4 it has changed to overriding a variable like this:

override var prefersStatusBarHidden: Bool {   return true } 

If you want to "Update" the state once the view controller is already being displayed, you will need to call:

setNeedsStatusBarAppearanceUpdate() 

Please refer to the documentation.

like image 191
Pochi Avatar answered Sep 21 '22 13:09

Pochi