UINavigationBar class provides a control for navigating hierarchical content. It’s a bar, typically displayed at the top of the screen, containing buttons for navigating within a hierarchy of screens. The primary properties are a left (back) button, a center title, and an optional right button. You can use a navigation bar as a standalone object or in conjunction with a navigation controller object.
- iOS 2.0+
- tvOS 2.0+
Using a Navigation Bar With a Navigation Controller
The most common way to use a navigation bar is in conjunction with a
UINavigationController object. If you use a navigation controller to manage the navigation between different screens of content, the navigation controller creates the navigation bar automatically and pushes and pops navigation items when appropriate.
A navigation controller automatically assigns itself as the delegate of its navigation bar object. Therefore, when using a navigation controller, don’t assign a custom delegate object to the corresponding navigation bar.
For information about navigation controllers, see
Customizing the Appearance of a Navigation Bar
In iOS 5.0 and later, you can customize the appearance of the bar using the methods listed in Customizing the Bar Appearance. You can customize the appearance of all navigation bars using the appearance proxy (
[UINavigationBar appearance]), or just of a single bar.
In iOS 7, a navigation bar’s
tintColor affects the color of the back indicator image, button titles, and button images. The
barTintColor property affects the color of the bar itself. Additionally, navigation bars are translucent by default. Turning the translucency off or on does not affect buttons, since they do not have backgrounds.
In general, when a property is dependent on the bar metrics (on the iPhone in landscape orientation, bars have a different height from standard), be sure to specify a value for
default as well as for other metrics.
For more information about appearance and behavior configuration, see Navigation Bars.