2
votes

I am trying to change the text color in the status bar and everything within the navigation.

I am using this code:

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

This code does work, however I receive a caution:

Implicit conversion from enumeration type 'enum UIStatusBar' to different enumeration type 'UIBarStyle' (aka) 'enum UIBarStyle').

Could someone tell me what I am doing wrong?

Peter

1
What is the base iOS SDK version you are using? Please note that the enum "UIStatusBarStyleLightContent" is available for iOS7.0 and upwards only. - Subzero
Works like a charm for me.. I assume that you are using iOS7 since you never answered Subzero about it? - Daniel Larsson
I have answered him. I am on xcode 5 running on 7.0 - Peter Stuart
Apparently, the line above is correct and should not throw a warning. However, can you please elaborate as to what you mean when you say "navigation status bar"? Do you mean to say only the status bar or is there a navigation bar/controller as well in your code? - Subzero
The code you posted is not the problem. Some where else you must be setting the barStyle property (or calling the setBarStyle: method) and passing one of the UIStatusBarStyle... values by mistake instead of one the UIBarStyle... values. - rmaddy

1 Answers

2
votes

For updating status bar color you can do this

[self setNeedsStatusBarAppearanceUpdate]; 

and you should have this defined

-(UIStatusBarStyle)preferredStatusBarStyle{
    return UIStatusBarStyleDefault;
}

for the navigation bar text color

[self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}];
[self.navigationItem.title = @"Test"];