iOS7.0以后状态栏样式设置及隐藏

1.在Xcode info.plist中设置

198DC2CB-4A30-4B83-94FC-F9075820F933.png

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

你可能感兴趣的:(iOS7.0以后状态栏样式设置及隐藏)