Setting Light Status Bar Objective-C iOS 10 - ios

I am trying to set the status bar to while (light). I have tried everything but still cannot figure out what is going wrong.
In Info.plist I have the following:
View controller-based status bar appearance NO
- (UIStatusBarStyle)preferredStatusBarStyle
{
return UIStatusBarStyleLightContent;
}

Related

Status Bar not showing on iPhone 4S

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

iOS 8 light status bar not working

I've set the background color of the main UIView in my view controller to a bluish color.
I've also tried all combinations of the following:
Adding this to the app delegate:
UIApplication.sharedApplication().setStatusBarStyle(UIStatusBarStyle.LightContent, animated: true)
Setting View controller status based application to NO and YES
Setting 'Status Bar Style' to Light in the project overview.
I'm seeing black status bar text when I want to see white text.
I'd like to set the style at the application level, not the VC level.
My info.plist:
for all IOS 9+
In your plist file change add/change your table with these 2 lines.
1) View controller-based status bar appearance to NO
2) Status bar style to UIStatusBarStyleLightContent
If you want to change style in running app for any reason use this
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
this saved my life numerous times! :-)
Status bar style is determined (by default) at the level of the view controller, not the application. Implement preferredStatusBarStyle in your view controller.
class ViewController : UIViewController {
override func preferredStatusBarStyle() -> UIStatusBarStyle {
return .LightContent
}
}
You can determine status bar style at the application level, but to do so, you must throw a switch in your Info.plist. See the docs:
To opt out of the view controller-based status bar appearance behavior, you must add the UIViewControllerBasedStatusBarAppearance key with a value of NO to your app’s Info.plist file, but doing so is not recommended [my italics, and I don't even know whether this is even supported any longer].
Swift 4
In Info.plist add this property
View controller-based status bar appearance to NO
and after that in AppDelegate inside the didFinishLaunchingWithOptions add these code
UIApplication.shared.isStatusBarHidden = false
UIApplication.shared.statusBarStyle = .lightContent
you can use this code
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
might be Solve this issue.

Dynamically change status bar text color

I know I can change the iPhone's status bar text color, using methods described here.
However, my app has different themes, and I need to update the status bar accordingly.
Calling
[self setNeedsStatusBarAppearanceUpdate];
and
-(UIStatusBarStyle)preferredStatusBarStyle{
return UIStatusBarStyleLightContent;
}
will obviously not work. However, it needs to be local, as in only for a specific TabBar view.
First, select your Project and in the Genernal tab you will see something like this.
enter image description here
Then set Status Bar Style to Light just like the image.
Second, set View controller-based status bar appearance equal to NO in Info.plist. If you can't find it, just add a new row and set it like the above step.
And then, run your app you will see the Status bar text colour is white. :)
Just for the ones who come here for the title.
You can set a flag and toggle between the status bar text colors like in the code segment given:
-(UIStatusBarStyle)preferredStatusBarStyle {
if (barStyleLight){
return UIStatusBarStyleLightContent;
}
else {
return UIStatusBarStyleDefault;
}
}
Also note that, this preferredStatusBarStyle method is called whenever we call: [self setNeedsStatusBarAppearanceUpdate];
Hope it helps.

UIStatusBarStyle battery color is green [duplicate]

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;
}

Top bar color when keyboard is dismissed during search

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.

Resources