Consider the following code:
struct ContentView: View {
var body: some View {
NavigationStack {
Text("Text")
.navigationTitle("Title")
.toolbar {
Button("Button", systemImage: "line.3.horizontal.decrease.circle.fill", action: {})
.symbolRenderingMode(.hierarchical)
.foregroundStyle(.blue)
}
}
}
}
If I modify the code by adding a second button,
.toolbar {
HStack {
Button("Button", systemImage: "line.3.horizontal.decrease.circle.fill", action: {})
.symbolRenderingMode(.hierarchical)
Button("Button", systemImage: "line.3.horizontal.decrease.circle.fill", action: {})
.symbolRenderingMode(.hierarchical)
.foregroundStyle(.blue)
}
}
However, this is of course far from ideal. I tried adding an "empty" Button("", action: {})
instead to the HStack and it works, but it's really just a hack.
Any ideas ?
When creating the button's image yourself, the color is respected:
.toolbar {
Button(action: {}) {
Image(systemName: "line.3.horizontal.decrease.circle.fill")
.symbolRenderingMode(.hierarchical)
.foregroundStyle(.blue)
}
Looks like a bug in Button
.