iOS/Swift
[Swift] Top Notch, Bottom Notch 높이 구하기 (iPhoneX 이상 노치 )
clyne_dev
2021. 5. 20. 22:31
안녕하세요.
iOS 개발자 CNOO 입니다!
오늘은 간단하게, 아이폰의 Top Notch 및 Bottom Notch의 높이를 구하는 코드를 작성해보도록 하겠습니다.
노치란??
static func bottomNotchHeight() -> CGFloat {
if #available(iOS 11.0, tvOS 11.0, *) {
return UIApplication.shared.delegate?.window??.safeAreaInsets.bottom ?? 0
}
return 0
}
static func TopNotchHeight() -> CGFloat {
if #available(iOS 11.0, tvOS 11.0, *) {
return UIApplication.shared.delegate?.window??.safeAreaInsets.top ?? 0
}
return 0
}