Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/100.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 是否清除SwiftUI中表单部分的背景?_Ios_Swiftui_Ios14 - Fatal编程技术网

Ios 是否清除SwiftUI中表单部分的背景?

Ios 是否清除SwiftUI中表单部分的背景?,ios,swiftui,ios14,Ios,Swiftui,Ios14,我正在尝试删除一些部分的白色背景,以便元素正好位于灰色背景上,但我无法删除或透明部分背景 这就是我正在尝试的: struct ContentView: View { var body: some View { Form { Section { Text("Hello!") Button { print("C

我正在尝试删除一些部分的白色背景,以便元素正好位于灰色背景上,但我无法删除或透明部分背景

这就是我正在尝试的:

struct ContentView: View {
    
    var body: some View {
        Form {
            Section {
                Text("Hello!")
                Button {
                    print("Clicked")
                } label: {
                    Text("Click Me!!")
                }
            }
            Section {
                VStack {
                    Button("Button 1") {}
                    Spacer()
                    Button("Button 2") {}
                }
            }
            .background(Color.clear) // Not doing anything
            Section {
                VStack(alignment: .leading) {
                    Text("Location")
                        .font(.headline)
                    Group {
                        Text("Abc")
                        Text("Abc")
                        Text("Abc")
                    }
                    .font(.caption)
                }
            }
        }
    }
}
这就是它看起来的样子:


我试图将
.background(Color.clear)
添加到
部分
VStack
,但没有任何效果。如何在SwiftUI中实现这一点?

即使在SwiftUI 2
中,表单
也构建在UIKit之上,特别是
UITableView

您需要删除默认的
UITableViewCell
背景(仅一次,最好在App
init
中):

并使用以下命令更改背景:

Section {
    VStack {
        Button("Button 1") {}
        Spacer()
        Button("Button 2") {}
    }
}
.listRowBackground(Color.clear)

我想这会改变全球所有表格单元格的状态吗?但还是感觉不舒服。Color.clear应该可以自己工作。相反,这似乎非常接近:
.listRowBackground(Color(.systemGroupedBackground))
@TruMan1,表单是一个标准的外观控件。对标准控制的任何未正式记录的更改都是一种黑客行为,可以停止任何系统更新。若修改器对它并没有影响,那个就意味着它不应该有影响。其他一切由你自己承担风险。
Section {
    VStack {
        Button("Button 1") {}
        Spacer()
        Button("Button 2") {}
    }
}
.listRowBackground(Color.clear)