toolbarTitleAlignment(_:)
Sets the preferred alignment of the navigation bar’s title.
Declaration
nonisolated func toolbarTitleAlignment(_ alignment: ToolbarTitleAlignment) -> some View
Parameters
- alignment:
The preferred navigation title alignment.
Discussion
The navigation bar resolves the alignment of its title automatically based on context, and toolbar roles. Use this modifier to override that resolution.
NavigationStack {
ContentView()
.navigationTitle("Library")
.toolbarTitleAlignment(.center)
}