Reputation: 2304
I am writing a picker and it lists a bunch of icons.
Picker("Icons ", selection: $selectedIcon) {
ForEach(icons, id: \.self) { icon in
HStack {
Image(systemName: icon)
.foregroundColor(Color.red) // This doesn't work
}.padding()
}
}
In the above code, SwiftUI picker doesn't change the color of the icon to red in the picker's menu-item as per foreground color. Any idea how to change color of an image within picker menu-item?
Upvotes: 5
Views: 1475
Reputation: 1
Use .foregroundStyle(Color1, Color2)
But only Color1
will be displayed.
Upvotes: -1
Reputation: 36807
try using .foregroundStyle(.red, .blue)
,
works for me.
Upvotes: 6