UIStatusBar changes style for no apparent reason

2019-07-17 04:34发布

问题:

I have an app in which I set the UIStatusBarStyle to UIStatusBarStyleLightContent and it works perfectly fine for a while. Then, as suddenly than unexpectedly, it changes to UIStatusBarStyleDefault for no apparent reason.

View controller-based status bar appearance property is set to NO.

Is there a specific place which I should set the UIStatusBarStyle in? Currently I set it in - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions before anything else.

Thank you very much for any clues.

回答1:

You have to set .plist file like :

write each view-controller :

-(UIStatusBarStyle)preferredStatusBarStyle
{
  if [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
    return UIStatusBarStyleLightContent;// for black color 
  }else
  {
     return UIStatusBarStyleDefault;// set as default
  }
}

Hope it will help.

happy coding...