I have 2 UIViewControllers
. In the first UIViewController
, say ViewController1
, I am keeping the UINavigationBar
hidden. As my app's theme is black , so I need white UIStatusBar
in iOS 7
so that it doesn't become invisible in black UINavigationBar
. For getting white UIStatusBar
I am using this method in iOS 7
.
- set the
UIViewControllerBasedStatusBarAppearance
toYES
in theplist
- in
viewDidLoad
do a[self setNeedsStatusBarAppearanceUpdate];
add the following method:
-(UIStatusBarStyle)preferredStatusBarStyle{ return UIStatusBarStyleLightContent; }
It works fine when I am in ViewController1 . But when I move to ViewController2 then if I set
self.navigationController.navigationBarHidden = NO
in my viewDidLoad
method. Then the above code for white UIStatusBar
doesn't work. UIStatusBar
becomes black and I can't see it because I am using the following codes to customize my UINavigationBar
self.navigationController.navigationBar.barTintColor = [UIColor blackColor];
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
self.navigationController.navigationBar.titleTextAttributes = [NSDictionary dictionaryWithObject:[UIColor whiteColor] forKey:UITextAttributeTextColor];
self.navigationController.navigationBar.translucent = NO;
If I keep UINavigationBar
hidden like ViewController1 then white UIStatusBar
is visible again. But when UINavigationBar
is visible then status bar becomes black again. That's the problem.
Can anyone help me in this context , how can I get white status bar like my ViewController1 ? Thanks in advance.