我正在尝试制作一个类似于这样的列表:
无论我尝试什么,都无法弄清楚如何使列表和部分都具有.clear
背景,目前看起来是这样的:
.background(Color.clear)
添加到列表和部分中,但没有成功。
当我使用除clear以外的任何颜色时,它都可以正常更改。但似乎在背景色之后有一些东西,使其仍然显示白色和灰色...
如何将此列表更改为完全透明?
这是我当前失败的尝试:
var body: some View {
NavigationView {
List {
ForEach(uniqueEntries, id: \.self) { category in
Section(header: HStack {
Text(category)
.font(.headline)
.foregroundColor(.white)
.padding()
Spacer()
}
.listRowInsets(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 0))
.background(Color.clear)
) {
ForEach(self.entriesCollatedByCategory[category]!) { entry in
ExpenseRow(entry: entry)
.listRowInsets(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 0))
.listRowBackground(Color.clear)
}
}
}
}
.padding()
.background(Image("tempGradientBackground")
.resizable()
.aspectRatio(contentMode: .fill))
.navigationBarTitle(Text("Budget"))
}.background(Color.clear)
}
.listStyle(InsetGroupedListStyle())
- 这应该更符合OP的要求(至少我是这么认为的)。 - pawello2222