1 | initial version |
You can modify the font size of the NavigationTitle in SwiftUI by setting the titleTextAttributes modifier on the navigation bar. Here's an example:
NavigationView {
Text("Hello World!")
.navigationTitle("My Title")
.navigationBarTitleDisplayMode(.inline)
.navigationBarTitle("My Title")
.navigationBarTitleDisplayMode(.inline)
}
.navigationViewStyle(StackNavigationViewStyle())
.onAppear {
let appearance = UINavigationBarAppearance()
appearance.largeTitleTextAttributes = [
NSAttributedString.Key.font: UIFont.systemFont(ofSize: 36)
]
UINavigationBar.appearance().standardAppearance = appearance
UINavigationBar.appearance().compactAppearance = appearance
UINavigationBar.appearance().scrollEdgeAppearance = appearance
}
In this example, we set the font of the title to be a system font with a size of 36. You can adjust the size to fit your needs. The appearance object is used to set the font for all the different states of the navigation bar (standard, compact, and scroll edge). Finally, we apply the appearance to the navigation bar using the UINavigationBar.appearance() method.