Created
September 18, 2019 14:31
-
-
Save iosharry/53bcc00643e8237a97d0ce7eacb06134 to your computer and use it in GitHub Desktop.
iOS13 StatusBar Crash Issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private var statusBarView: UIView? | |
if #available(iOS 13.0, *) { | |
let tag = 38482458385 | |
if let statusBar = UIApplication.shared.keyWindow?.viewWithTag(tag) { | |
statusBarView = statusBar | |
} else { | |
let statusBar = UIView(frame: UIApplication.shared.statusBarFrame) | |
statusBar.tag = tag | |
UIApplication.shared.keyWindow?.addSubview(statusBar) | |
statusBarView = statusBar | |
} | |
} else { | |
statusBarView = UIApplication.shared.value(forKey: "statusBar") as? UIView | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
아 아카이브 하려니 똑같은 에러가 발생하네요.
StatusBar Frame만큼 View를 그려서 addSubView하는 방식이네요. 공유해주셔서 감사합니다.
추가적으로, UIStatusBarManager를 통해서 StatusBar Frame가져올 수 있어요! 아래 코드 참조하시면 좋을 것 같습니다:)
let statusBarFrame = UIApplication.shared.keyWindow?.windowScene?.statusBarManager?.statusBarFrame
let statusBar = UIView(frame: statusBarFrame)
view.addSubView(statusBar)