You want to add buttons to a navigation bar.
A navigation bar can contain different items. Buttons are often
displayed on the left and the right sides. These buttons are of class
UIBarButtonItem and can take many
different shapes and forms. Let’s have a look at an example in Figure 2-32.
Figure 2-32. Different buttons displayed on a navigation bar
You might be surprised that the bar on the
bottom of Figure 2-32 is also a
navigation bar! Navigation bars are of class
can be created at any time and added to any view. So just look at all
the different buttons with different shapes that have been added to
the navigation bars in Figure 2-32. The ones
on the top right have up and down arrows, the one on the top left has
an arrow pointing to the left, and the ones on the bottom navigation
bar have all sorts of shapes. We will have a look at creating some of
these buttons in this recipe.
In order to create a navigation button, we must:
Create an instance of
Add that button to the navigation bar of a view controller
using the view controller’s