Graphics Programs Reference
In-Depth Information
A navigation item can hold more than just a title string, as shown in Figure 11.15 . There
are three customizable areas for each UINavigationItem : a leftBarBut-
tonItem , a rightBarButtonItem , and a titleView . The left and right bar but-
ton items are pointers to instances of UIBarButtonItem , which contains the informa-
tion for a button that can only be displayed on a UINavigationBar or a UIToolbar .
Figure 11.15 UINavigationItem with everything
Like UINavigationItem , UIBarButtonItem is not a subclass of UIView but
supplies the content that a UINavigationBar needs to draw. Consider the UINavig-
ationItem and its UIBarButtonItem s to be containers for strings, images, and oth-
er content. A UINavigationBar knows how to look in those containers and draw the
content it finds.
The third customizable area of a UINavigationItem is its titleView . You can
either use a basic string as the title or have a subclass of UIView sit in the center of the
navigation item. You cannot have both. If it suits the context of a specific view controller
to have a custom view (like a button, a slider, an image, or even a map), you would set the
titleView of the navigation item to that custom view. Figure 11.15 shows an example
of a UINavigationItem with a custom view as its titleView . Typically, however,
a title string is sufficient, and that's what we'll do in this chapter.
Let's add a UIBarButtonItem to the UINavigationBar . We want this button to sit
on the right side of the navigation bar when the ItemsViewController is on top of
the stack. When tapped, it should add a new BNRItem to the list.
 
Search WWH ::




Custom Search