Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 833
The Cook Avatar asked Dec 22 '25 19:12

The Cook


1 Answers

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;
}

OR

- (UIStatusBarStyle)preferredStatusBarStyle {

    return UIStatusBarStyleLightContent;
}
like image 86
Ronak Chaniyara Avatar answered Dec 24 '25 11:12

Ronak Chaniyara



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!