Search code examples
iosuinavigationbarstatusbar

Changing IOS7 statusbar content color


Hi I am developing small IOS application in which I am using simple one window with navigation controller. What I want to do is change status bar colour to white. For that I did following things.

[self.navigationController.navigationBar setBarTintColor:[UIColor redColor]];
[self.navigationController.navigationBar setBarStyle:UIBarStyleBlackTranslucent];
[self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];

It works fine.enter image description here

But now I don't want navigation bar and I hide it self.navigationController.navigationBarHidden = YES;

It removes navigation bar but it is not applying that white colour theme to my status bar. It again turn to black.

enter image description here

I don't want navigation bar but I want to change status bar content to white. How to do this. Need Help. Thank you.


Solution

  • Use UIStatusBarStyleLightContent.

    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
    
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:YES];
    

    Also, change the UIViewControllerBasedStatusBarAppearance in your PLIST file to NO.

    NOTE: This question has been asked before. Please research a little more for questions like this.