'statusBarFrame' was deprecated in iOS 13.0: Use the statusBarManager property of the window scene !


★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★

➤微信公眾號:MindDraft
➤博主域名:https://www.zengqiang.org
➤GitHub地址:https://github.com/strengthen/LeetCode
➤原文地址:https://www.cnblogs.com/strengthen/p/12109327.html
➤如果鏈接不是山青詠芝的博客園地址,則可能是爬取作者的文章。
➤原文已修改更新!強烈建議點擊原文地址閱讀!支持作者!支持原創!
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★

熱烈歡迎,請直接點擊!!!

進入博主App Store主頁,下載使用各個作品!!!

注:博主將堅持每月上線一個新app!!!

由於未捕獲的異常“ NSInternalInconsistencyException”而終止應用程序,原因:“在UIApplication上名為-statusBar或-statusBarWindow的應用程序:必須更改此代碼,因為不再有狀態欄或狀態欄窗口。而是在窗口場景上使用statusBarManager對象。”

但是目前尚不清楚應如何使用它來更改顏色,因為keyWindow?.windowScene?.statusBarManager它似乎不包含與之相關的任何內容。

 1 //MARK: 擴展UIApplication
 2 extension UIApplication {
 3     var statusBarUIView: UIView? {
 4         
 5         if #available(iOS 13.0, *) {
 6             let tag = 3848245
 7             
 8             let keyWindow = UIApplication.shared.connectedScenes
 9                 .map({$0 as? UIWindowScene})
10                 .compactMap({$0})
11                 .first?.windows.first
12             
13             if let statusBar = keyWindow?.viewWithTag(tag) {
14                 return statusBar
15             } else {
16                 let height = keyWindow?.windowScene?.statusBarManager?.statusBarFrame ?? .zero
17                 let statusBarView = UIView(frame: height)
18                 statusBarView.tag = tag
19                 statusBarView.layer.zPosition = 999999
20                 
21                 keyWindow?.addSubview(statusBarView)
22                 return statusBarView
23             }
24             
25         } else {
26             
27             if responds(to: Selector(("statusBar"))) {
28                 return value(forKey: "statusBar") as? UIView
29             }
30         }
31         return nil
32 }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM