The Cook The Cook - 1 year ago 134
Swift Question

Presented View Controller Status Bar Color is Different, How to Change It To Default?

I have a presented view controller. However its status bar color is different then its navigation bar color. How do I make sure they are same color?

Answer Source

Try below code, if it help:

Set same style as current viewController to viewController being presented as follows:

//newViewController is your ViewController

newViewController.navigationBar.barStyle = self.navigationController.navigationBar.barStyle;

[self presentViewController:newViewController animated:YES completion:nil];

Also, If you are using a navigation controller and want to control the status bar on a per view controller basis, you'll want to subclass UINavigationController and implement preferredStatusBarStyle.

- (UIStatusBarStyle)preferredStatusBarStyle
    return self.topViewController.preferredStatusBarStyle;


- (UIStatusBarStyle)preferredStatusBarStyle {

    return UIStatusBarStyleLightContent;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download