Non-collapsing title

In the Photos app, the Collections title doesn't collapse into a small inline title when scrolling, unlike a standard inline large title display mode. How is this implemented?

Answered by Jordan in 913790022

You can achieve this with the following code in your view controller:

navigationItem.style = .editor // Left align title view
navigationItem.titleView = titleLabel
Accepted Answer

You can achieve this with the following code in your view controller:

navigationItem.style = .editor // Left align title view
navigationItem.titleView = titleLabel

Thanks, that works! Here's the SwiftUI version:

.navigationTitle("Collections") // needed for the back button menu
.toolbarTitleAlignment(.leading) // or .toolbarRole(.editor)
.toolbarTitleDisplayMode(.inline) // or .navigationBarTitleDisplayMode(.inline)
.toolbar {
    ToolbarItem(placement: .principal) {
        Text("Collections")
            .font(.largeTitle.bold())
    }
}

Is there a way to get the same result without a custom toolbar item?