The iOS 7 Transition Guide give a good hint how to change the UIStatusBarStyle
dynamically in a UIViewController
using
- (UIStatus
You need a ViewController that's showing in Fullscreen to return the appropriate status bar infos. In your case: The NavigationController which contains ModalViewController needs to implement preferredStatusBarStyle
and return UIStatusBarStyleLightContent
.
A call to setNeedsStatusBarAppearanceUpdate
is only necessary if the values a view controller returns actually change. When the view controller is first presented they are queried anyway.
All of the above work. However sometimes I find it really a pain in the bottom to go and change every instance in the Storyboard etc... So here's something that works for me that also involves subclassing.
First create the subclass:
@interface HHNavLightColorBarController : UINavigationController
@end
@implementation HHNavLightColorBarController
- (UIStatusBarStyle)preferredStatusBarStyle {
return UIStatusBarStyleLightContent;
}
@end
Then using the magic of Objective-C and a little bit of the <objc/runtime.h>
When you have a reference of the view controller and your presenting it:
UINavigationController *navVC = ...; // Init in your usual way
object_setClass(navVC, [HHNavLightColorBarController class]);
[self presentViewController:nav animated:YES completion:^{
NSLog(@"Launch Modal View Controller");
}];
Sometimes it seems a bit less intrusive. You could probably even create a category that checks to see if your kindOfClass is a navigation controller and auto do it for you. Anyways, the answer is above by jaetzold, I just found this to be handy.
Just look up if your app's rootViewController need to override -(UIStatusBarStyle)preferredStatusBarStyle method