Reputation: 698
Here's a GIF showing the issue:
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?
Upvotes: 0
Views: 457
Reputation: 781
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)
}
Upvotes: 1