반응형
KeyWindow 가져오기 위해 사용하던 코드들이 iOS 버젼에 따라 deprecated 됨에 따라서
편하기 사용하기 위한 keyWindow 가져오기 Extension
extension UIApplication {
var keyWindow: UIWindow? {
connectedScenes.filter { $0.activationState == .foregroundActive }.compactMap { $0 as? UIWindowScene }.first?.windows.first { $0.isKeyWindow }
}
}
// how to use
UIApplication.shared.keyWindow?.safeAreaInsets
반응형
'iOS > Tip' 카테고리의 다른 글
UIView -> UIImage (0) | 2023.11.15 |
---|---|
iOS 16.4 이후부터 WebView 디버깅 하기 (0) | 2023.11.15 |
iOS App URL Cache 제거 (0) | 2023.11.10 |
iOS 16이상에서 TextKit 1을 사용하고자 할때 (0) | 2023.10.22 |
Left Constraint 와 Leading Constraint 의 차이점 (0) | 2023.05.31 |
Intrinsic Size (0) | 2023.05.31 |
setNeedsLayout와 setNeedsDisplay의 차이 (0) | 2023.05.31 |
NSCache와 Dictionary로 캐쉬를 구성했을때 차이 (0) | 2023.05.31 |