How to hide a status bar in iOS?
IosStatusbarIos Problem Overview
I can hide a status bar in my app:
- (void)viewDidLoad{
[[UIApplication sharedApplication] setStatusBarHidden:YES];
[super viewDidLoad];
}
When I chose my launch image and start it first time, it's status bar over a picture. How can I hide this?
Ios Solutions
Solution 1 - Ios
You need to add this code in your AppDelegate file, not in your Root View Controller
Or add the property Status bar is initially hidden in your plist file
Folks, in iOS 7+
please add this to your info.plist file, It will make the difference :)
For iOS 11.4+ and Xcode 9.4 +
Use this code either in one or all your view controllers
> override var prefersStatusBarHidden: Bool { > return true }
Solution 2 - Ios
Add the following code to your view controller:
if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) {
// iOS 7
[self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)];
} else {
// iOS 6
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
}
- (BOOL)prefersStatusBarHidden {
return YES;
}
Solution 3 - Ios
What helped me is this (changing plist file):
- set Status bar is initially hidden = YES
- add row: View controller-based status bar appearance = NO
Solution 4 - Ios
Put this code to your view controller in which you hide status bar:
- (BOOL)prefersStatusBarHidden {return YES;}
Solution 5 - Ios
In iOS 7 status bar appearance depends on UIViewController
as default. To hide status bar globally, in info.plist
use NO
value for UIViewControllerBasedStatusBarAppearance
key and use UIApplication
's setStatusBarHidden
method with YES
BOOL
value.
Solution 6 - Ios
add this key key from dropdownlist in "info.plist" and voila you will no more see top bar that includes elements something like GSM,wifi icon etc.
Solution 7 - Ios
It's working for me ,
Add below code into the info.plist file ,
<key>UIStatusBarHidden</key>
<false/>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
Hopes this is work for some one .
Solution 8 - Ios
In info.plist
View controller-based status bar appearance NO
Status bar is initially hidden YES
In view controller.m
- (BOOL) prefersStatusBarHidden
{
return YES;
}
Solution 9 - Ios
I am supporting iOS 5, 6, & 7. My app is iPad only. I needed to use all of the following:
[[UIApplication sharedApplication] setStatusBarHidden:YES];
View Controller:
- (BOOL)prefersStatusBarHidden{ return YES; }
Info.plist
<key>UIStatusBarHidden</key>
<string>YES</string>
<key>UIStatusBarHidden~ipad</key>
<true/>
<key>UIViewControllerBasedStatusBarAppearance</key>
<string>NO</string>
Solution 10 - Ios
Just check the box on Targets/Summary iPad Deployment Info and you status bar will disappear. It works on my apps.
Solution 11 - Ios
I had the same problem, but its an easy fix! Just set
status bar is initially hidden = YES
then add an row by clicking on the plus right after the text status bar is initially hidden
, then set the text to
view controller-based status bar appearance
by clicking the arrows, and set it to NO
Hope this helps!
Solution 12 - Ios
Well the easiest way that I do it is by typing the following into the .m file.
- (BOOL) prefersStatusBarHidden
{
return YES;
}
This should work!
Solution 13 - Ios
-(void) viewWillAppear:(BOOL)animated
{
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
}
Solution 14 - Ios
A complete solution in swift, in your view controller
// you can use your own logic to determine if you need to hide status bar
// I just put a var here for now
var hideStatusBar = false
override func preferStatusBarHidden() -> Bool {
return hideStatus
}
// in other method to manually toggle status bar
func updateUI() {
hideStatusBar = true
// call this method to update status bar
prefersStatusBarHidden()
}
Solution 15 - Ios
To hide status bar for each individual view controller programmatically, use any of the following two procedures:
Procedure 1:
[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
Procedure 2:
-(BOOL)prefersStatusBarHidden {
return YES;
}
To hide status bar for the entire application, we should follow the given below procedure:
You should add this value to plist: "View controller-based status bar appearance" and set it to "NO".