I would like to change my visionOS app's title font to Copperplate, but the Simulator just ignores my code. I know that I'm modifying the right attributes because changing the foregroundColor to red works, it's just the font that always remains the default system title font and size. Here's my code, where everything in init() seems to have no effect at all:
struct ContentView: View
{
@Environment(ViewModel.self) private var model
init()
{
let appearance = UINavigationBarAppearance()
appearance.titleTextAttributes = [.font: UIFont(name: "Copperplate", size: UIFont.preferredFont(forTextStyle: .title1).pointSize)!]
UINavigationBar.appearance().standardAppearance = appearance
UINavigationBar.appearance().scrollEdgeAppearance = appearance
}
var body: some View
{
@Bindable var model = model
NavigationStack(path: $model.navigationPath)
{
BooksView()
.tabItem { Label("Books", systemImage: "book") }
.navigationTitle("Title Test")
// .navigationDestination is also provided of course
}
}
}
However, configuring the appearance like this works fine:
appearance.titleTextAttributes = [.foregroundColor: UIColor.red]
Is this a limitation of the visionOS Simulator, or of visionOS, or am I doing something wrong?