I'm trying to make all the texts in my SwiftUI project use the SF Mono font. Normally, I can just use the .monospaced() modifier on views to enable it. However, this doesn't work on the navigationTitle:
NavigationStack {
VStack {
// this works
Text("Hello World")
.monospaced()
}
// this doesn't
.navigationTitle("Title here").monospaced()
}
How would I make this work?
Edit: The solutions from this post (Set the Navigation Bar Title Font with SwiftUI) didn't work for me:
init() {
UINavigationBar.appearance().largeTitleTextAttributes = [.font : UIFont(name: "SFMono-Regular", size: 20)!]
}
or
NavigationStack {
Text("Hello World!").navigationBarTitle(Text("Dashboard").font(.system(.largeTitle, design: .monospaced)))
}
Anything I'm missing? Maybe, the new NavigationStack in iOS16 is the problem?