簡體   English   中英

如何在UIImagePickerController覆蓋整個屏幕之前防止狀態欄消失?

[英]How to prevent status bar disappearing before UIImagePickerController covers the whole screen?

這是顯示問題的GIF:

在此處輸入圖片說明

當呈現這樣的UIImagePickerController

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

在圖像選擇器全屏顯示之前,狀態欄會消失。

我的問題是,隨着狀態欄消失在煙霧中,導航欄跳起來,占據了狀態欄所留下的空白。 關閉UIImagePickerController ,狀態欄將顯示在其應有的位置。

我目前沒有以任何方式自定義狀態欄,默認情況下都是如此。

有沒有一種方法可以防止UIStatusBar消失,至少要等到UIImagePickerController動畫完成為止?

如果希望狀態欄停留在屏幕頂部,則應創建一個自定義窗口並手動應用動畫。 這可能會有所幫助:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM