2

I have a view controller (view1) that prefers a hidden status bar. I have a button that presents another view controller (view2) modally from the bottom of the screen (a 'Show' segue in my storyboard) and view2 prefers a visible status bar. On iOS 8, this is a smooth transition from view1 to view2, but on iOS 9 the status bar immediately appears in view1 when I press the button and the entire view of view1 shifts down to accommodate it.

This is an ugly effect and I wish to avoid it. For some reason iOS 8 handles this much more gracefully than iOS 9. Is there a fix for this?

Kevin_TA
  • 4,575
  • 13
  • 48
  • 77

1 Answers1

0

In Swift, you can set a global variable on view2 as

isStatusBarHidden = false

on viewWillAppear of view2 change it to true and update status bar

isStatusBarHidden = true
setNeedsStatusBarAppearanceUpdate()

the status bar delegate function will look like

func prefersStatusBarHidden() {
    return isStatusBarHidden
}

this only works in Swift, not Objective-C.

Kevin_TA
  • 4,575
  • 13
  • 48
  • 77
Subash
  • 1,002
  • 13
  • 26
  • Good tip. On 9.3 and 10.1, I also needed to wrap the `setNeedsStatusBarAppearanceUpdate()` call in an animation block. – Kevin Owens Nov 27 '16 at 12:58