The items to be displayed by a navigation bar when the associated view controller is visible.
SDKs
- iOS 2.0+
- Mac Catalyst 13.0+
- tvOS 9.0+
Framework
- UIKit
Declaration
@interface UINavigationItem : NSObject
Overview
When building a navigation interface, each view controller pushed onto the navigation stack must have a UINavigation
object that contains the buttons and views it wants displayed in the navigation bar. The managing UINavigation
object uses the navigation items of the topmost two view controllers to populate the navigation bar with content.
A navigation item always reflects information about the view controller with which it is associated. The navigation item must provide a title to display when the view controller is topmost on the navigation stack. In addition, the item may contain additional buttons to display on the right (or trailing) side of the navigation bar. You can specify buttons and views to display on the left (or leading) side of the toolbar using the left
property but the navigation controller displays those buttons only if there is space available.
The back
property of a navigation item reflects the back button you want displayed when the current view controller is just below the topmost view controller. In other words, the back button is not used when the current view controller is topmost.
When specifying buttons for a navigation item, you must use UIBar
objects. If you want to display custom views in the navigation bar, you must wrap those views inside a UIBar
object before adding them to the navigation item.