获取安全区域插入顶部和底部高度
答
试试这个:
在目标C
if (@available(iOS 11.0, *)) {
UIWindow *window = UIApplication.sharedApplication.keyWindow;
CGFloat topPadding = window.safeAreaInsets.top;
CGFloat bottomPadding = window.safeAreaInsets.bottom;
}
在斯威夫特
if #available(iOS 11.0, *) {
let window = UIApplication.shared.keyWindow
let topPadding = window?.safeAreaInsets.top
let bottomPadding = window?.safeAreaInsets.bottom
}
我更新了答案 – Ladislav
感谢那是铅,我还想着。我不认为有更可靠的解决方案。但有了这个,我只能得到完全不安全的高度,对吧?每个区域的高度不是两个? – Tulleb
一旦意见被列出来,这将给你正确的答案 – Ladislav