gpt4 book ai didi

ios - 检测iPhone是缺口屏幕还是普通矩形屏幕,以避免导航栏尺寸问题?

转载 作者:行者123 更新时间:2023-12-01 19:42:12 24 4
gpt4 key购买 nike

我像在个人资料屏幕中执行whatsapp一样,在顶部实现可扩展横幅时遇到了一个问题。当用户滚动图像压缩并转换为导航栏时。为此,我必须在代码中设置最小高度,但是由于iphone X和其他新iphone的缺口屏幕,这会导致问题。因为旧的iPhone没有缺口屏幕,所以导航栏的高度小于新的iPhone?

那么有什么办法可以找出iPhone的陷波屏还是普通屏呢?

最佳答案

这样,您可以检测到缺口屏幕:

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
}

关于ios - 检测iPhone是缺口屏幕还是普通矩形屏幕,以避免导航栏尺寸问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53779671/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com