【问题标题】:Get height of status bar before it shows?在显示之前获取状态栏的高度?
【发布时间】:2016-05-12 19:45:03
【问题描述】:

在我的应用程序中有一个视图,可以根据需要显示或隐藏状态栏,并且过渡是动画的。当扩展状态栏处于活动状态时,它将我的视图向下推 20pt 并离开屏幕。

为了解决这个问题,我需要在状态栏显示之前检测它的高度,并触发动画来调整视图的大小:

- (BOOL)prefersStatusBarHidden {
    return _statusHidden;
}

- (BOOL)prefersStatusBarUpdateAnimation {
    return UIStatusBarAnimationSlide;
}

- (void)showStatusBar:(CGFloat)delay {
    _statusHidden = NO;

    // how do I set this value?
    CGFloat extendedStatusBarHeight = ??? - 20;   

    [UIView animateWithDuration:0.2f delay:delay options:0 animations:^{
        [self setNeedsStatusBarAppearanceUpdate];
        self.wrapper.frame = CGRectMake(x,y,w,h - extendedStatusBarHeight)
    } completion:nil];
}

如何获取状态栏显示前的高度?

【问题讨论】:

    标签: ios ios9 uistatusbar


    【解决方案1】:

    你可以试试这个:

    CGRectGetHeight([UIApplication sharedApplication].statusBarFrame);
    

    【讨论】:

      猜你喜欢
      • 2013-12-15
      • 2011-04-22
      • 1970-01-01
      • 2018-08-16
      • 2010-12-22
      • 1970-01-01
      • 2018-06-24
      • 1970-01-01
      • 2019-11-23
      相关资源
      最近更新 更多