Search code examples
objective-cios7uinavigationbarstatusbaruistatusbar

StatusBar colour never changes when using NavigationBars on iOS 7


I am trying to change the app StatusBar colour and it works ONLY when my XIB has no navigationBars. To do so, I added the following function to my source file:

-(UIStatusBarStyle)preferredStatusBarStyle{
    return UIStatusBarStyleLightContent;
}

But when I call [self.navigationController setNavigationBarHidden:NO animated:NO]; the status bar goes back to the default style.

It leads me to believe that the navigation bar should set the statusBar colour for itself.

Ant suggestions?


Solution

  • Fixed this setting a unique StatusBar colour for the whole app instead of doing it for each ViewController. It took only 2 steps:

    1. Defined “View controller-based status bar appearance” = NO on MyAppName-Info.plist

    2. Added the following line to my - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions AppDelegate function

    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

    It worked for me =)