0

There is a view in my app where the status bar can be shown or hidden on demand and the transition is animated. When the extended status bar is active, it pushes my view 20pt down and offscreen.

To fix this, I need to detect the height of the status bar before it shows, and trigger an animation to resize the view:

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

How can I get the height of the status bar before it shows?

Cbas
  • 6,003
  • 11
  • 56
  • 87

1 Answers1

-2

You can try this:

CGRectGetHeight([UIApplication sharedApplication].statusBarFrame);
brianha289
  • 338
  • 1
  • 8