0

Here's a GIF showing the issue:

enter image description here

When presenting a UIImagePickerController like this:

self.present(imagePicker, animated: true, completion: nil)

the status bar disappears before the image picker is full screen.

The issue I have with this is that as the status bar disappears in a cloud of smoke, the navigation bar jumps up occupying the void left by the status bar. When UIImagePickerController is dismissed, the status bar shows up in its rightful place.

I'm currently not customizing the status bar in any way, all default.

Is there a way to prevent UIStatusBar from disappearing, at the very least until UIImagePickerController animation is complete?

  • Do you want to show the status bar on the camera screen that's it? – Victor Casé Aug 14 '17 at 21:03
  • No, I don't want the status bar when taking a picture. I just want it to stay in place during the presenting animation, instead of disappearing just when the animation starts. I want the view I have before presenting `UIImagePickerController`to stay exactly the same (my vc with the status bar) and `UIImagePickerController` on top of that. – Andrés Pizá Bückmann Aug 15 '17 at 15:55
  • Ah ok, sorry I understand it now. That is a default behavior and also it is recommended by the Apple UI Guidelines "Consider temporarily hiding the status bar when displaying full-screen media. A status bar can be distracting when users are trying to focus on media. Temporarily hide these elements to provide a more immersive experience. The Photos app, for example, hides the status bar and other interface elements during browsing of full-screen photos." [1] https://developer.apple.com/ios/human-interface-guidelines/ui-bars/status-bars/ – Victor Casé Aug 16 '17 at 16:55

1 Answers1

1

If you want your status bar to stay at the top of your screen, you should create a custom window and apply animations manually. This may help:

var newWindow = UIWindow()
let newController = viewControllerToPresent()
var animationDuration = 0.4 // or whatever you want.
// setting newController as root of new window.
self.window.rootViewController = newController
self.window.windowLevel = UIWindowLevelStatusBar
self.window.backgroundColor = .clear
self.window.frame = CGRect(x: 0, y: UIScreen.main.bounds.height, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)
self.window.isHidden = false

UIView.animate(withDuration: animationDuration) { 
    self.window.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)
}
Yusuf Kamil AK
  • 771
  • 8
  • 17