代码之家  ›  专栏  ›  技术社区  ›  Daniel

如何使用SwiftUI v2(2020)InsetGroupedListStyle列表的背景色

  •  0
  • Daniel  · 技术社区  · 4 年前

    我正在尝试设置列表的背景颜色;但它仍然是灰色的。

    var body: some View {
            
            List {
                ForEach(...) {
                    Section() {
                        Text("not the actual code")
                    }
                }
            }
            .listStyle(InsetGroupedListStyle())
            .background(Color.red)
        }
    

    .listRowBackground(Color.green) 适用于行,但不适用于表的背景颜色

    0 回复  |  直到 4 年前
        1
  •  1
  •   Anil Kumar    4 年前

    使用颜色相乘(颜色:)

    List {
            ForEach(...) {
                Section() {
                    Text("not the actual code")
                }
            }
        }.colorMultiply(Color.green).padding(.top)