I have a grouped list:
How to change the systemGroupedBackgroundColor
of the List
?
Here is the code:
struct View2: View {
var array = ["1", "2", "3"]
@State private var selected: String?
var body: some View {
List(array, id:\.self) { value in
Text("\(value) Navigation 1")
.listRowBackground(Color.green)
NavigationLink("", destination: View1())
}.background(Color.red)
.listStyle(GroupedListStyle())
}
}
struct ContentView: View {
var body: some View {
NavigationView {
VStack {
View2()
}
}.navigationBarTitle("Navigation")
}
}
I've tried set the background
of the List
to Red, but doesn't work. Like below. Thanks!
Insert the following code into
View2
and it should work: