I am looking for a way to change the stroke / fill color of an SF Symbol icon in SwiftUI.
I have tried .background(Color.red)
but that just changes the background of the whole icon (no change is applied to the actual icon itself) as implied. I also tried .foregroundColor(Color.red)
which does nothing to the icon.
contents of content view are as follows:
var body: some View {
Image(systemName: "person.circle").foregroundColor(.red)
}
You can change the stroke and fill color of a sf symbol icon using foregroundColor(_ color: Color?)
The following code:
Image(systemName: "flame.fill").foregroundColor(.red)
Image(systemName: "flame").foregroundColor(.red)
Should produce this:
Here is the complete SwiftUI View Code
struct Icon : View {
var body: some View {
HStack{
Image(systemName: "flame.fill")
.foregroundColor(.red)
Image(systemName: "flame")
.foregroundColor(.red)
}
.padding()
}
}