Remove/change section header background color in SwiftUI List

后端 未结 6 1448
旧巷少年郎
旧巷少年郎 2021-02-12 12:56

With a simple List in SwiftUI, how do I change/remove the standard background color for the section header

struct ContentView : View {
    var body:         


        
6条回答
  •  耶瑟儿~
    2021-02-12 13:16

    Another way you can do it by setting the frame of the header:

            VStack {
                List {
                    ForEach(0...3) { section in
                        Section(header:
                            Text("Section")
                                .frame(minWidth: 0, maxWidth: .infinity,alignment:.leading)
                                .background(Color.blue.relativeWidth(2))
                        ) {
                            ForEach(0...3) { row in
                                Text("Row")
                            }
                        }
                    }
                }
            }
    

提交回复
热议问题