主要有UIWindow
,它包含MainViewController
,它使用lightContent
作爲preferredStatusBarStyle
。我創建了第二個UIWindow
實例來顯示PopupViewController
,它使用default
作爲preferredStatusBarStyle
。關閉第二個UI窗口後恢復狀態欄狀態
當我表明第二UIWindow
與PopupViewController
狀態欄樣式更改default
,但是當我把它隱藏樣式不更改回lightContent
。
同樣的問題適用於當我在彈出窗口中隱藏狀態欄的情況下使用VC的情況 - 當彈出窗口被解除時狀態欄不顯示。
新UIWindow
創作:
// Prepare window to show dialog box in
newWindow = UIWindow(frame: UIScreen.main.bounds)
newWindow?.windowLevel = 3
// Overlay new window
newWindow?.makeKeyAndVisible()
self.mainWindow.windowLevel = 1
self.mainWindow.endEditing(true)
newWindow?.isHidden = false
// Display dialog
newWindow?.rootViewController = PopupViewController()
新UIWindow
解僱:
UIView.animate(
withDuration: 1.0,
delay: 0,
usingSpringWithDamping: 1,
initialSpringVelocity: 0,
options: .curveEaseOut,
animations: { [weak self] in
self?.newWindow?.alpha = 0
},
completion: { [weak self] _ in
self?.newWindow?.windowLevel = 0
self?.newWindow?.rootViewController = nil
self?.newWindow?.alpha = 1
self?.mainWindow.makeKeyAndVisible()
}
)
謝謝!
編輯:彈出窗口可以出現在任何時間,我不知道哪個VC是活躍在那一刻
Popup可以出現在隨機的VC上。手動設置樣式對我來說感覺很不好。我認爲有一些方法可以告訴「好的,現在這個窗口再次成爲主人,這裏是rootVC,繼承它的狀態欄設置」。 –
您是否在「info.plist – Ragul
」中將「基於控制器的狀態欄外觀」設置爲NO?不幸的是,我需要它基於VC的 –