我对此代码有疑问:
UIWindow* rootWindow = UIApplication.sharedApplication.windows.firstObject;
CGRect myRectInWindow = [sv convertRect:sv.bounds toView:rootWindow];
sv是表格视图。从根窗口计算myRectInWindow的事实使结果忽略了安全区域。在这里如何考虑安全区域?
您可以使用此方法获得安全区域
if #available(iOS 11.0, *) {
if let window = UIApplication.shared.keyWindow{
let topPadding = window.safeAreaInsets.top
let bottomPadding = window.safeAreaInsets.bottom
// your code
}
}