Search code examples
iosobjective-cswiftios9ios-animations

Hiding status bar while in UIViewControllerAnimatedTransitioning


I have implemented a interactive dismissal animation for a controller that is being presented full screen.

The issue is that whenever I try to dismiss it status bar appearsimage

The full screen controller has its - (BOOL)prefersStatusBarHidden returning true so the bar isn't visible when presented.

The presenting view controller is embedded in a navigation controller.

Thing's I've tried:

  • setting - (BOOL)prefersStatusBarHidden to true and calling setNeedsStatusBarAppearanceUpdate in viewWillAppear in the presenter

  • changing the presenters navigationController.navigationBar.barStyle properties

Twitter app has the bar hidden when dismissing, so I guess this must be possible

twitter


Solution

  • I have achieved the same status bar behavior as in the Twitter app.

    The secret is to change the [[UIApplication sharedApplication] keyWindow]'s UIWindowLevel to UIWindowLevelStatusBar before the presentation animation and change it back to UIWindowLevelNormal (or whatever your window's level was) after the dismissal.