title
The navigation item’s title that displays in the navigation bar.
Declaration
var title: String? { get set }Discussion
The default value is nil.
When the navigation item is on the navigation item stack and is second from the top — in other words, its view controller manages the views that the user would navigate back to — the value in this property is used for the back button on the top-most navigation bar. If the value of this property is nil, the system uses the string “Back” as the text of the back button. In iOS 11 and later, the size and position of the title is determined by the prefersLargeTitles property of the navigation bar and the largeTitleDisplayMode property of the navigation item.
Display content in a toolbar on Mac
For Mac apps built with Mac Catalyst, the system can display a navigation bar’s content in an NSToolbar. When the system displays a navigation bar’s content in a toolbar, title and subtitle are only supported when you associate the navigation bar with the UINavigationBar.NSToolbarSection.content section of the toolbar. The system ignores values from all other sections. NSToolbar doesn’t support a navigation item’s titleView, large titles, or attributed titles, regardless of section.
For more information about when the system displays a navigation bar’s content in a toolbar, see Building with Mac Catalyst.
When present, title and subtitle take precedence over the window scene’s title and subtitle. To avoid displaying an orphaned scene subtitle, the system only uses the scene’s subtitle when the navigation item hasn’t set a title. These values appear in the standard locations NSWindow uses, rather than above the navigation item’s column.