Only with iphone 6/6 plus the status bar is blank, I don't see anything while on iphone 5, ipad 3 (both with iOS8) all work perfectly, I add:
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
on
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
I also add: View controller-based status bar appearance NO but nothing, where is the mistake?
There could be two possibilities.
Either this property is present in your plist. (Status bar style : UIStatusBarStyleLightContent) and your viewcontroller's background is also whiteColor.
or
Your status bar is set to be hidden initially or by the code [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
Kindly check your view background. It could be either black & the statusBar is also Default or it background is white & statusBar is LightContent.
Hope that helps.
Try to add UIStatusBarHidden (Status bar is initially hidden) with value YES in your Info.plist
From the comment above, you mentioned that you want to show the Status bar.
If so, put the following code inside whichever view controller that you want the status bar to appear.
- (BOOL)prefersStatusBarHidden {
return NO;
}
For the PList:
View controller-based status bar appearance: NO (means that you want to hide it)
View controller-based status bar appearance: YES (means that you want to show it)
For more information, please see: setStatusBarHidden not working
The above link is about hiding the Status bar. If you want to show it, I think you can just try the exact opposite.
Related
I have the status bar set to UIStatusBarStyleLightContent and in all other devices (5, 5S, 6, 6 Plus) the status bar is showing in white text. The background color of my app is black, so the status bar has a black background, thats why I need the status bar text to be white.
So only when I test on the 4S does the status bar text show as black. Is this a known bug? Is there any work around on making the 4S have the correct status bar style?
This is why I have done
in AppDelegate:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
application.statusBarStyle = UIStatusBarStyleLightContent;
}
in each ViewController within my app I put this in viewDidLoad and add this method:
- (void) viewDidLoad {
[self setNeedsStatusBarAppearanceUpdate];
}
- (UIStatusBarStyle)preferredStatusBarStyle
{
return UIStatusBarStyleLightContent;
}
Also, in my info.plist I have this:
Status bar style = UIStatusBarStyleLightContent
Have you tried this?
Set "View controller-based status bar appearance" (UIViewControllerBasedStatusBarAppearance) to YES in your Info.plist. (YES is the default, so you can also just leave this value out of your plist.)
I have 6 view controllers. I'd like to set the status bar of my first view controller to black and then the other 5 to white. All view controllers are in a push stack.
I've tried to implement
[self setNeedsStatusBarAppearanceUpdate]
- (UIStatusBarStyle) preferredStatusBarStyle {
return UIStatusBarStyleLightContent;
}
That does not seem to work. I've also tried playing with the apps plist properties. Any ideas?
If you want to change Background colour of status bar then that's possible.
you have to change UIWindow 's background colour to your preferred colour. try following
e.g.
[[UIApplication sharedApplication].delegate window].backgroundColor = [UIColor orangeColor];
and if you want to change text colour then just try
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
You have missed this settings in Plist
View controller-based status bar appearance to YES
Do the following things.
View controller-based status bar appearance = NO in plist.
The ViewController that you want to make white in ViewwillApper add
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
The ViewController that you want to make Black in ViewwillApper add
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
How can I hide the navigation bar by not hiding the status bar in my app? When I try [self.navigationController.navigationBar setHidden:YES]; it also hides the status bar. I need to show the status bar like this:
I need to first hide a visible navigation bar, make the status bar still visible and I also have a view that I need to move below the status bar, but the view is being positioned like the navigation bar is still there when I set the frame's position to 0,0.
I setup my statusbar as:
[[UIApplication sharedApplication] setStatusBarHidden:NO];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
Add this to your code where you want to hide the navigation bar
[self.navigationController.navigationBar setHidden:YES];
If you want to hide navigation bar but show status bar, you should set Top Space to Top Layout Guide as 0 instead of -44. and then
Hide navigation bar in viewWillAppear instead of viewDidLoad: [self.navigationController setNavigationBarHidden:YES animated:YES]
I start to set top space as -44, then call method [[UIApplication sharedApplication] setStatusBarHidden:NO], it doesn't work.
In my case, the status bar text and symbols were not shown because they had the same color as the background (black). I solved the problem by changing the background color:
[self.navigationController.navigationBar.superview setBackgroundColor:UIColor.whiteColor];
This question already has an answer here:
UIStatusBarStyleLightContent Not setting battery white?
(1 answer)
Closed 9 years ago.
Alright I have my UIStatusBarStyle set to white with this
-(UIStatusBarStyle)preferredStatusBarStyle
{
return UIStatusBarStyleLightContent;
}
and it's working BUT….. The status bar battery icon is green, how are we supposed to change that?
About the battery being green it's green only when charging the iDevice, when not charging the battery icon goes white or black according to the style of your statusbar.
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
or
If you prefer to opt out of having view controllers adjust the status bar style—and instead set the status bar style by using the UIApplicationstatusBarStyle method—add the UIViewControllerBasedStatusBarAppearance key to an app’s Info.plist file and give it the value NO.
Or
try this
Set "View controller-based status bar appearance" (UIViewControllerBasedStatusBarAppearance) to YES in your Info.plist. (YES is the default, so you can also just leave this value out of your plist.)
your class viewDidLoad method, call [self setNeedsStatusBarAppearanceUpdate].
To Implement preferredStatusBarStyle, returning the status bar style that you want for this view controller.
-(UIStatusBarStyle) preferredStatusBarStyle {
return UIStatusBarStyleLightContent;
}
I have light top bar colors in my app, because the navigation bar is dark brown:
When I tap search (Keresés here), the following code sets the top bar color to dark content:
- (void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller
{
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
}
- (void)searchBarTextDidEndEditing:(UISearchBar *)searchBar
{
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}
So it looks like this:
But when I type something into the field, then scroll the results list, the keyboard dismisses and the top bar is reverted to white. How can I prevent this?
In iOS 7, the status bar style is, by default, determined by the return value of the UIViewController method -preferredStatusBarStyle. The default implementation of this method returns UIStatusBarStyleDefault.
Setting the info.plist key UIViewControllerBasedStatusBarAppearance to the value of NO returns to the pre-iOS 7 style of taking the status bar appearance from the shared UIApplication object
To fix this you have two options:
1) Implement the -preferredStatusBarStyle method in all your view controllers that want the status bar style to be non-default
2) Add the key "View controller-based status bar appearance" (UIViewControllerBasedStatusBarAppearance) to your info.plist file and set its value to NO
The solution is in this comment: https://stackoverflow.com/a/19513714/511878
Summary: UINavigationController does not forward -preferredStatusBarStyle to it's children.