2017-01-31 2 views
2

ステータスバーを表示するViewControllerから、ステータスバーを表示しないViewControllerから切り離しています。iOSがアニメーション中にステータスバーを表示しなくなるのを修正しました。

アニメーション中に、新しいViewControllerが上にスライドするので、ステータスバーがすぐに古いViewController上をスライドしているのが見えます。

これがなぜ起こっているのか、これを修正する方法を教えてください。

enter image description here

新しいのViewControllerが原因に何のステータスバーを持っていない:

override var prefersStatusBarHidden: Bool { 
    return true 
} 

プレゼンテーションのスタイルは

modalPresentationStyle = "overCurrentContext"

NEW次のとおりです。問題とテストXcodeプロジェクトに作成

:新しいのViewControllerが古いステータスバーの上に滞在ようにするには https://github.com/paul301/TestSlideUp

答えて

1

を、あなたは新しいUIWindowを作成し、手動でアニメーションを行う必要があります。
サンプルコード:

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) 
    } 
} 
+0

これは前にそれから良く見えますが、今新しいのViewControllerは、それが消える前に一瞬のためにステータスバーを持ってしまいます。ステータスバーの上をスライドするといいですね – pflous

+0

@pflous更新 – jokeman

+0

ありがとうございます! – pflous

関連する問題