No need to change appearance of all lists or do anything strange, just:
- (Optional) Put
.listStyle(GroupedListStyle())
on yourList
if you do not want sticky headers. - Set the
listRowInsets
on the section to 0. - Set the
Section.backgroundColor
toclear
to remove the default color, or whatever color you want to color it.
Example:
List {
Section(header: HStack {
Text("Header")
.font(.headline)
.foregroundColor(.white)
.padding()
Spacer()
}
.background(Color.blue)
.listRowInsets(EdgeInsets(
top: 0,
leading: 0,
bottom: 0,
trailing: 0))
) {
// your list items
}
}.listStyle(GroupedListStyle()) // Leave off for sticky headers