1.在Xcode info.plist中设置
2.在viewContent中重写系统方法
- (UIStatusBarStyle)preferredStatusBarStyle
{
return UIStatusBarStyleLightContent;
}
- (BOOL)prefersStatusBarHidden
{
return NO;
}
- (UIStatusBarAnimation)preferredStatusBarUpdateAnimation
{
return UIStatusBarAnimationFade;
}
3.如果- (UIStatusBarStyle)preferredStatusBarStyle没有调用是因为viewContent存在导航控制器需要在导航控制器中实现- (UIStatusBarStyle)preferredStatusBarStyle如下
- (UIStatusBarStyle)preferredStatusBarStyle
{
return UIStatusBarStyleLightContent;
}
如果还是存在不调用的情况就在- (void)viewDidAppear:(BOOL)animated中主动调用
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)])
{
[self preferredStatusBarStyle];
}
}