问题
I am facing an issue in implementing expandable banner on top like whatsapp do in profile screen. When user scroll image squeezes and convert into navigation bar. For that i have to set minimum height in my code but due to notch screen in iphone X and other new iphones it causing issue. Because old iphone doesnot have notch screen so there navigation bar height is less than new iphones?
So there is any way to find out the iphone is notch screen or normal type screen?
回答1:
This way you can detect notch screen:
extension UIDevice {
var hasNotch: Bool {
let bottom = UIApplication.shared.keyWindow?.safeAreaInsets.bottom ?? 0
return bottom > 0
}
}
if UIDevice.current.hasNotch {
// consider notch
} else {
// don't have to consider notch
}
来源:https://stackoverflow.com/questions/53779671/detect-whether-iphone-is-of-notch-screen-or-normal-rectangle-screen-to-avaid-nav