Currently trying to determine if there is a way to programmatically set colors in SwiftUI.
Here's an example of the code I have that doesn't work.
ForEach(listItems, id: \.self) { item in
Text(item.name).listRowBackground(Color(item.color))
}
However manually specifying the color like so does.
ForEach(listItems, id: \.self) { item in
Text(item.name).listRowBackground(Color.red)
}
Just wanting to know if anyone else has determined a way dynamically set this with a large selection of colors.
Thanks