How can I change the background colour of a list in SwiftUI.

Hey guys. I'm working on an app for the Swift Student Challenge and I found a problem. Each time I try to change the color of a whole list, nothing happens. For example, I tried to use .background(Color.black), but the list stayed gray.

Please help as fast as you can.

Much appreciated, mrhn_huor

Answered by CMDdev in 750328022

Try .scrollContentBackground(.hidden) in combination with .background(.black).

scrollContentBackground(_:) is a new modifier introduced last year. You can find the documentation here.

Accepted Answer

Try .scrollContentBackground(.hidden) in combination with .background(.black).

scrollContentBackground(_:) is a new modifier introduced last year. You can find the documentation here.

apparently you can't do that. You can apply a custom row background to each item in the list, using .listRowBackground(Color(.black)), for example.

How can I change the background colour of a list in SwiftUI.
 
 
Q