Class

UINavigation​Item

A UINavigation​Item object manages the buttons and views to be displayed in a UINavigation​Bar object. When building a navigation interface, each view controller pushed onto the navigation stack must have a UINavigation​Item object that contains the buttons and views it wants displayed in the navigation bar. The managing UINavigation​Controller object uses the navigation items of the topmost two view controllers to populate the navigation bar with content.

Overview

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​Bar​Button​Items property but the navigation controller displays those buttons only if there is space available.

The back​Bar​Button​Item 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​Button​Item objects. If you want to display custom views in the navigation bar, you must wrap those views inside a UIBar​Button​Item object before adding them to the navigation item.

For information about how navigation items work together with a navigation controller, custom view controllers, and the navigation bar to display their content, see View Controller Programming Guide for iOS.

Symbols

Initializing an Item

init(title:​ String)

Returns a navigation item initialized with the specified title.

Getting and Setting Properties

var title:​ String?

The navigation item’s title displayed in the center of the navigation bar.

var prompt:​ String?

A single line of text displayed at the top of the navigation bar.

var back​Bar​Button​Item:​ UIBar​Button​Item?

The bar button item to use when a back button is needed on the navigation bar.

var hides​Back​Button:​ Bool

A Boolean value that determines whether the back button is hidden.

func set​Hides​Back​Button(Bool, animated:​ Bool)

Sets whether the back button is hidden, optionally animating the transition.

var left​Items​Supplement​Back​Button:​ Bool

A Boolean value indicating whether the left items are displayed in addition to the back button.

Customizing Views

var title​View:​ UIView?

A custom view displayed in the center of the navigation bar when the receiver is the top item.

var left​Bar​Button​Items:​ [UIBar​Button​Item]?

An array of custom bar button items to display on the left (or leading) side of the navigation bar when the receiver is the top navigation item.

var left​Bar​Button​Item:​ UIBar​Button​Item?

A custom bar button item displayed on the left (or leading) edge of the navigation bar when the receiver is the top navigation item.

var right​Bar​Button​Items:​ [UIBar​Button​Item]?

An array of custom bar button items to display on the right (or trailing) side of the navigation bar when the receiver is the top navigation item.

var right​Bar​Button​Item:​ UIBar​Button​Item?

A custom bar button item displayed on the right (or trailing) edge of the navigation bar when the receiver is the top navigation item.

func set​Left​Bar​Button​Items([UIBar​Button​Item]?, animated:​ Bool)

Sets the left bar button items, optionally animating the transition to the new items.

func set​Left​Bar​Button(UIBar​Button​Item?, animated:​ Bool)

Sets the custom bar button item, optionally animating the transition to the new item.

func set​Right​Bar​Button​Items([UIBar​Button​Item]?, animated:​ Bool)

Sets the right bar button items, optionally animating the transition to the new items.

func set​Right​Bar​Button(UIBar​Button​Item?, animated:​ Bool)

Sets the custom bar button item, optionally animating the transition to the view.

Relationships

Inherits From