In my iOS video app status bar is hidden in some view controllers. I have done this using following code.
[[UIApplication sharedApplication] setStatusBarHidden:YES];
It works for iOS 5 and iOS 6 , but not in iOS 7.
I tried with this in particular view controller,
Eg:
-(BOOL)prefersStatusBarHidden { return YES; }
It works well, but I cant show status bar again in the parent view controller.
In the Plist add the following properties.
now the status bar will hidden.
Here is the Swift version (pre iOS9):
This also works (iOS7+):
You also need to call:
in say
viewDidLoad()
.Note that if you use a SplitView controller, or some other
container
view controller, you also need to have it return your class when its sentchildViewControllerForStatusBarHidden
. One way to do this is have a public weak var for saystatusController
, and return it in this overridden method.FIXED SOLUTION FOR SWIFT 3+ (iOS 9, 10)
1- In info.plist set below property
2- Paste below code to Root controller , To
You can call
isStatusBarHidden = true
andisStatusBarHidden = false
where you want tohide/show
status barBut it gets more interesting when there's a UINavigationController involved:
For better understanding add some photos with comments:
App before any changes
Found in your
Project Navigator
folder namedSupporting Files
and click on *.plist fileAfter you will get different setting of your app showed. You need to add 2 keys
UIStatusBarHidden
andUIViewControllerBasedStatusBarAppearance
. You can do this simply clicking on + buttonAfter pressing + you can choose one of the key - just start to type.
Correct version:
And finally application after applying this changes:
Also, you can find alternative solution here
Try this simple method:
Objective-C:
Swift: