struct ContentView:View {
@State var color=false
varbody:someView {
List {…}.listBackground (color?.white:.black)
Toggle ("text", isOn:$color)
}
}
does not change the color.
I wonder if the writing method is different.
Also, it does not change to .listRowBackground(color?white:.black))
.
scrollContentBackground
to hide
does not change.
Can't I change the color of the cell?
swift swiftui
.listRowBackground()
should be attached to each View
cell, not to the entire List
.
import SwiftUI
struct ContentView:View {
@State var isBasicColor=true
varbody:someView {
List{
Text ("Blue")
.listRowBackground (isBasicColor?Color.blue:.red)
Text ("Red")
.listRowBackground (isBasicColor?Color.red:.white)
Text ("Yellow")
.listRowBackground (isBasicColor?Color.yellow:.blue)
}
.padding()
Toggle ("Cell colors", isOn: $isBasicColor)
}
}
© 2024 OneMinuteCode. All rights reserved.