I am segueing from a ViewController with a status bar to one without.
During the animation I'm seeing the status bar quickly slide up on the old ViewController as the new ViewController is sliding on top.
Any suggestions why this is happening and how to fix this?
The new ViewController has no status bar due to:
override var prefersStatusBarHidden: Bool {
return true
}
Presentation style is
modalPresentationStyle="overCurrentContext"
NEW:
Created a test XCode project with the issue: https://github.com/paul301/TestSlideUp
To make the new ViewController stay on top of the old status bar, you need to create a new UIWindow and do the animation manually.
Sample code:
var window = UIWindow()
//to show new view controller
func showWindow() {
let vc = NewViewController()
self.window.rootViewController = vc
self.window.backgroundColor = UIColor.clear
self.window.windowLevel = UIWindowLevelStatusBar
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: 0.5) {
self.window.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)
}
}