I tried many ways to set the status bar style (default or lightcontent) but can't get it to work on a per view controller basis. I can set the status bar style for the whole app only.
Does anyone have a hint?
I tried UIViewControllerBasedStatusBarAppearance
and
-(UIStatusBarStyle)preferredStatusBarStyle{ return UIStatusBarStyleLightContent; }
but these methods don't work.
Click on the View Controller corresponding to the view that you want to be the initial view. Open the Attributes Inspector. Select the "Is Initial View Controller" check box in the View Controller section.
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.)
In your viewDidLoad method, call [self setNeedsStatusBarAppearanceUpdate]
.
Implement preferredStatusBarStyle
, returning the status bar style that you want for this view controller.
- (UIStatusBarStyle) preferredStatusBarStyle { return UIStatusBarStyleLightContent; }
There is a catch here if your view controller is inside standalone UINavigationController and not a part of Storyboard based UINavigationController then above all methods fail. I came across this situation and then in order to set the status bar to light style i used following
[self.navigationController.navigationBar setBarStyle:UIBarStyleBlack];
This worked perfectly for me.
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