Reading time: 1 min

This recipe shows how to change List background color in SwiftUI.

The end result looks like this:

Screenshot%202022-08-14%20at%2018.10.31 Screenshot%202022-08-14%20at%2018.11.22

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)

Next Post Previous Post