본문 바로가기
iOS/iOS

아이폰 노치 여부 확인 방법

by 패쓰킴 2022. 1. 24.
728x90
 var safeAreaBottom:CGFloat = 0.0
        
if #available(iOS 15.0, *) {
  guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene else { return }
  safeAreaBottom = (windowScene.keyWindow?.safeAreaInsets.bottom)!
} else {
  let keyWindow = UIApplication.shared.windows.first{$0.isKeyWindow}
  safeAreaBottom = (keyWindow?.safeAreaInsets.bottom)!
}
        
if safeAreaBottom > 0.0 {
  UserDefaults.standard.set(safeAreaBottom, forKey: "isNotchiPhone")
} else {
  UserDefaults.standard.set(safeAreaBottom, forKey: "isNotchiPhone")
}

 

참고:

https://www.thedget.com/19

728x90

'iOS > iOS' 카테고리의 다른 글

ERROR 모음  (0) 2022.02.17
타이머  (0) 2022.01.25
navigation bar 숨김 시 swipe  (0) 2022.01.21
Dark mode  (0) 2022.01.12
info.plist  (0) 2022.01.12

댓글