Logo for tanaschita.com

Customizing the appearance of the NavigationView title in SwiftUI

Learn how to create a custom navigation bar title view in SwiftUI.

updated on 20 Jan 2025 · 3 min read

Note: Starting with iOS 16, NavigationStack provides more robust navigation handling, such as support for deep linking, programmatic navigation, and improved management of state. While NavigationView remains available for backward compatibility, it's recommended to use NavigationStack for modern SwiftUI projects.

In this article, we'll look at how to customize the navigation title for NavigationView. Let's jump in.

Sponsorship logo
Architecture & Design Patterns for iOS
This book is a practical guide to essential architectural principles and design patterns for iOS development. It covers strategies for building maintainable apps with Swift and SwiftUI, including dependency injection, navigation, common patterns, and modularization.
LEARN MORE

The default NavigationView in iOS shows a large title when it's expanded and switches to an inline title when scrolled. The following code example results in such default behaviour.

NavigationView {
VStack {
/// List...
}
.navigationTitle("Title")
}

SwiftUI provides 2 options to customize the appearance of the title:

The navigationBarTitleDisplayMode(_:) modifier

By using the navigationBarTitleDisplayMode(_:) modifier and setting it to .inline disables the large title style. The title always stays within the standard bounds of the navigation bar.

var body: some View {
NavigationView {
VStack {
// List...
}
.navigationTitle("Title")
.navigationBarTitleDisplayMode(.inline)
}
}

The toolbar(content:) modifier

In case we need a custom appearance of the title, we can use the toolbar(content:) modifier.

var body: some View {
NavigationView {
VStack {
// List...
}
.navigationTitle("Title")
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .principal) {
Image(systemName: "photo.fill")
.foregroundColor(.green)
}
}
}
}

We set a ToolbarItem of placement type .principal with the content we want to show as a title view. If a navigation bar title is also configured, it gets overridden by the toolbar item.

We can replace the Imageview from the example above with any type of SwiftUI view hierarchy.

Sponsorship logo
Preparing for a technical iOS job interview
Preparing for a technical iOS Job Interview with over 300 questions & answers. Covering Swift & Objective-C, SwiftUI & UIKit, Combine, HTTP Networking, iOS File System, Core Data, Concurrency with async/await, Security, Automated Testing, Dependency Management, AI & Machine Learning and more.
LEARN MORE
Sponsorship logo
Architecture & Design Patterns for iOS
This book is a practical guide to essential architectural principles and design patterns for iOS development. It covers strategies for building maintainable apps with Swift and SwiftUI, including dependency injection, navigation, common patterns, and modularization.
LEARN MORE
Sponsorship logo
Become a sponsor of tanaschita.com
By publishing an article on different iOS topics every week, tanaschita.com is constantly growing in the developer community and may provide a great audience for you as a sponsor.
CLICK TO LEARN MORE

Newsletter

Image of a reading marmot
Subscribe

Like to support my work?

Say hi

Related tags

Articles with related topics

navigation

swiftui

swift

ios

How to persist navigation state in SwiftUI

Learn how to save and restore NavigationPath to maintain user context across app launches.

21 Apr 2025 · 4 min read

Latest articles and tips

© 2026 tanaschita.com

Privacy policy

Impressum