Extension 사용하기
extension UIWindow {
static var current: UIWindow? {
for scene in UIApplication.shared.connectedScenes {
guard let windowScene = scene as? UIWindowScene else { continue }
for window in windowScene.windows {
if window.isKeyWindow { return window }
}
}
return nil
}
}
extension UIScreen {
static var current: UIScreen? {
UIWindow.current?.screen
}
}
'SwiftUI' 카테고리의 다른 글
MatchedGeometryEffect (0) | 2024.04.12 |
---|---|
@discardableResult 반환값을 무시하게 만들기 (0) | 2024.04.12 |
onLongPressGesture 길게 눌렀을 때 동작하기 (0) | 2024.04.12 |
haptics / vibration (진동) (0) | 2024.04.12 |
Publishers and Subscribers (Combine) (0) | 2024.04.11 |