14
Aug
2022
SwiftUI List Background Color
Reading time: 1 min
This recipe shows how to change List background color in SwiftUI.
The end result looks like this:
This feature is available starting in SwiftUI 4 (iOS 16, macOS 12.4).
You might have noticed that setting background
on a List
doesn't work - it just gets ignored. However, if you also apply scrollContentBackground(.hidden)
, everything falls into place:
List {
Text("One")
Text("Two")
Text("Three")
}
.scrollContentBackground(.hidden) // HERE
.background(.green)