From https://stackoverflow.com/questions/45372550/preferredstatusbarstyle-is-not-working
If you want to set status bar style, application level then set UIViewControllerBasedStatusBarAppearance to NO in your .plist file. And in your appdelegate> didFinishLaunchingWithOptions add following ine.
[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:YES];
if you wan to set status bar style, at view controller level then follow these steps:
- Set the
UIViewControllerBasedStatusBarAppearancetoYESin the.plistfile, if you need to set status bar style at UIViewController level only. -
In the viewDidLoad add function -
setNeedsStatusBarAppearanceUpdate -
override preferredStatusBarStyle in your view controller.
-
-(void)viewDidLoad {[super viewDidLoad];[self setNeedsStatusBarAppearanceUpdate];}-(UIStatusBarStyle)preferredStatusBarStyle {returnUIStatusBarStyleLightContent;}
留言
張貼留言