How would I set the subtitle in a navigationbar in iOS26 via UIKit?

Asked on 2025-11-02

1 search

In iOS 26, you can set a subtitle in a UINavigationBar using the new Subtitle API provided by UINavigationItem. This allows you to render a subtitle below the title in the navigation bar. You can use attributed strings for fine-grained adjustments to both the title and subtitle. Here's a brief overview of how you might implement this:

  1. Create an Attributed String: Use an attributed string to define the subtitle, allowing for customization of font, color, and other attributes.

  2. Set the Subtitle: Assign the attributed string to the subtitle property of your UINavigationItem.

Here's a simple example in code:

let navigationItem = UINavigationItem(title: "Main Title")
let subtitleAttributes: [NSAttributedString.Key: Any] = [
    .font: UIFont.systemFont(ofSize: 14),
    .foregroundColor: UIColor.gray
]
let subtitle = NSAttributedString(string: "Subtitle", attributes: subtitleAttributes)
navigationItem.subtitle = subtitle

For more detailed information, you can refer to the session Build a UIKit app with the new design (08:54) from WWDC 2025, which covers the new design features in UIKit, including the navigation bar updates.