I need to let a specific ViewController embedded in an UINavigationController
to have light status bar text color (but other ViewController
s to behave differently). I am aware of at least 3 methods, none of which however work in my case.
How to change Status Bar text color in iOS 7, the method is primarily:
UIViewControllerBasedStatusBarAppearance
to YES
in the plist[self setNeedsStatusBarAppearanceUpdate];
Add the following method:
- (UIStatusBarStyle)preferredStatusBarStyle{
return UIStatusBarStyleLightContent;
}
Running on iOS 7.0.3, this method does not work for me, since even after I have implemented all 3 steps correctly, preferredStatusBarStyle
is never called.
UIStatusBarStyle PreferredStatusBarStyle does not work on iOS 7, the method is primarily:
Setting your navigationBar
’s barStyle
to UIBarStyleBlackTranslucent
will give white status bar text (ie. UIStatusBarStyleLightContent
), and UIBarStyleDefault
will give black status bar text (ie. UIStatusBarStyleDefault
).
This method works fair and square on iPhone, but not on iPad.
Setting the UIViewControllerBasedStatusBarAppearance
to NO
in the plist, and use
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
This clearly doesn't apply in this case, since I need to only specify different status bar colors for two of the ViewController
s.
Thanks for all help!
Step 1: After opening the android studio and creating a new project with an empty activity. Step 2: Navigate to res/values/colors. xml, and add a color that you want to change for the status bar.
You can change the status bar colour just with a single line of code. Just updated the markdown for iOS 13 and below.
Open your info. plist and set UIViewControllerBasedStatusBarAppearance to false . In the first function in AppDelegate. swift , which contains didFinishLaunchingWithOptions , set the color you want.
For people having this problem with a UINavigationController
I can recommend creating a custom UINavigationController
and implementing the preferredStatusBarStyle
on it like this:
- (UIStatusBarStyle)preferredStatusBarStyle
{
return [self.topViewController preferredStatusBarStyle];
}
That way the statusbar style will be that of the top view controller. Now you can implement the view controller's preferredStatusBarStyle
anyway you like.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With