How to hide status bar with animation in iOS 7?

前端 未结 1 570
我寻月下人不归
我寻月下人不归 2020-12-30 09:32

Since iOS 7 rolled out, I can\'t show or hide status bar with animation just like in iOS 6. For now I use NSTimer to control it when to hide.

here is my code:

相关标签:
1条回答
  • 2020-12-30 10:32

    You need to call

    [UIViewController setNeedsStatusBarAppearanceUpdate];
    

    from within an animation block as in the following example:

    @implementation SomeViewController {
        BOOL _statusBarHidden;
    }
    
    - (BOOL)prefersStatusBarHidden {
        return _statusBarHidden;
    }
    
    - (void)showStatusBar:(BOOL)show {
     [UIView animateWithDuration:0.3 animations:^{
            _statusBarHidden = !show;
            [self setNeedsStatusBarAppearanceUpdate];
        }];
    }
    
    @end
    
    0 讨论(0)
提交回复
热议问题