Swiftui GeometryProxy插图是否已随ios 14更改

Swiftui GeometryProxy插图是否已随ios 14更改,swiftui,ios14,Swiftui,Ios14,我在应用程序布局填充中遇到了一个错误。我使用一个几何读取器访问手机的安全区域插图,ios 13和ios 14有不同的行为。我读到geometryProxy发生了变化,但它没有提到安全区域插入 我有一个工作区,但我想有一个更理想的修复,我需要一些洞察力。 我将这两个函数添加到我的swiftUI视图中,并使用它们来计算在我的视图中似乎正常的填充 /** Hotfix */ public func getTopInsetPadding(_ geo: GeometryProxy) -> CGFlo

我在应用程序布局填充中遇到了一个错误。我使用一个几何读取器访问手机的安全区域插图,ios 13和ios 14有不同的行为。我读到geometryProxy发生了变化,但它没有提到安全区域插入

我有一个工作区,但我想有一个更理想的修复,我需要一些洞察力。 我将这两个函数添加到我的swiftUI视图中,并使用它们来计算在我的视图中似乎正常的填充

/** Hotfix */
public func getTopInsetPadding(_ geo: GeometryProxy) -> CGFloat {
    if #available(iOS 14, *) {
        return geo.safeAreaInsets.top
    } else {
        return geo.safeAreaInsets.top * 2
    }
}

/** Hotfix */
public func getBottomInsetPadding(_ geo: GeometryProxy) -> CGFloat {
    if #available(iOS 14, *) {
        return geo.safeAreaInsets.bottom
    } else {
        return geo.safeAreaInsets.bottom * 2
    }
}
 .padding(.top, self.getTopInsetPadding(geo))
 .padding(.bottom, self.getBottomInsetPadding(geo))
 .edgesIgnoringSafeArea(.all)
在我看来,我是这样使用它的

/** Hotfix */
public func getTopInsetPadding(_ geo: GeometryProxy) -> CGFloat {
    if #available(iOS 14, *) {
        return geo.safeAreaInsets.top
    } else {
        return geo.safeAreaInsets.top * 2
    }
}

/** Hotfix */
public func getBottomInsetPadding(_ geo: GeometryProxy) -> CGFloat {
    if #available(iOS 14, *) {
        return geo.safeAreaInsets.bottom
    } else {
        return geo.safeAreaInsets.bottom * 2
    }
}
 .padding(.top, self.getTopInsetPadding(geo))
 .padding(.bottom, self.getBottomInsetPadding(geo))
 .edgesIgnoringSafeArea(.all)
你知道我为什么要这么做吗

编辑:

删除.edgesIgnoringSafeArea(.all)将正确设置safeareaInset