SwiftUI 工作表模态背景不适用于 EdgeIgnoreSafeArea(.all) - 为什么?

Dav*_*vid 4 background swiftui

我正在使用 SwiftUI 工作表模式运行 iOS 13 模拟器 - 尝试绘制工作表背景并忽略安全区域 - 但仍然显示白色工作表。关于如何正确执行此操作有什么想法吗?


    var body: some View {
        VStack(alignment: .center, spacing: 0) {

... redacted ...

 }   // VStack
            .background(Color.gray.edgesIgnoringSafeArea(.all))
Run Code Online (Sandbox Code Playgroud)

带表单模式的 iPhone 模拟器

看图(附)

有什么想法我做错了吗?

Asp*_*eri 7

将顶部容器(VStack在您的情况下)扩展到整个纸张区域,例如

VStack {
    // ... your content
}
.frame(maxWidth: .infinity, maxHeight: .infinity)      // << here !!
.background(Color.gray.edgesIgnoringSafeArea(.all))
Run Code Online (Sandbox Code Playgroud)