Search code examples
iosobjective-cuistatusbar

Set status bar colour for different view controllers


I have 6 view controllers. I'd like to set the status bar of my first view controller to black and then the other 5 to white. All view controllers are in a push stack.

I've tried to implement

[self setNeedsStatusBarAppearanceUpdate]

- (UIStatusBarStyle) preferredStatusBarStyle { 
return UIStatusBarStyleLightContent; 
}

That does not seem to work. I've also tried playing with the apps plist properties. Any ideas?


Solution

  • If you want to change Background colour of status bar then that's possible. you have to change UIWindow 's background colour to your preferred colour. try following

    e.g.

    [[UIApplication sharedApplication].delegate window].backgroundColor = [UIColor orangeColor];
    

    and if you want to change text colour then just try

     [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];