struct ContentView: View {
var body: some View {
NavigationView {
List {
Text("Hi")
}
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .principal) {
Text("Title")
.font(.headline)
}
ToolbarItem(placement: .navigationBarLeading) {
Button(action: {}) {
Image(systemName: "person.circle")
.font(.largeTitle)
}
}
}
}
}
}
The .font(.largeTitle)
on Image
has no effect, only if I use it inside a button.
Is this a bug or am I doing something wrong?
It looks like SwiftUI treats single toolbar items differently (applies their own style, size etc).
A possible workaround is to put a Button
in a more complex view, as in: How to change color of ToolbarItem with navigationBarLeading placement in SwiftUI
Adapted to your example it can look like this:
ToolbarItem(placement: .navigationBarLeading) {
HStack {
Button(action: {}) {
Image(systemName: "person.circle")
.font(.largeTitle)
}
Text("")
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With