Change UINavigationBar Background
With the release of iOS 5, the UIAppearance protocol is used to access the appearance proxy for a class you would like to configure. Customization is done by sending messages to the target class appearance proxy. When changing the appearance of an object, all instances of the object can be updated or only specific instances within a container class.
Let’s see how this looks as it relates to updating the background color of a UINavigationBar, it’s text and the back button which will allow a user to return to a previous view controller.
The image below is the gradient that I will use for the background:
Using the above image, I created a one pixel wide image for both portrait and landscape variations of the navbar, reason being, the height of the navar bar when the device is in portrait mode is 44, whereas the height for landscape is 32.
The images in my project are NavigationPortraitBackground.png and NavigationLandscapeBackground.png, both shown below:
I now create two UIImage objects:
To set these images as the new backgrounds for all navigation bars, here’s all I need to do:
In addition to the color, I can change the appearance of the text on all navigations bars as well:
As the final step, I will update the back button with a custom image, which is shown below (the button is shown on a gray backdrop so you can see the white border):
Using what I described in the early post about cap insets, I can create a UIImage object and use the appearance API of the UIBarButtonItem to set the back button look. Notice that each value in the cap inset is set to 12, indicating all four corners are to hold steady at 12 pixels, even if the images stretched or resized.
The last step is to create a button for the user interface that will push a new view controller, which will update the navigation bar to show the custom back button created above.
An important concept to understand here, I’ve used the same image, blueButton.png, for both the custom back button as well as the button on the primary user interface – setting the cap insets specifies the rules, if you will, of how the image can be stretched, yet keep the look appropriate for the context in which the button will appear (that is, on the navbar or main UI).
A few screenshots follow that show the custom navigation bar, text and buttons in both portrait and landscape modes:
i copied this post from this link
http://mobiledevelopertips.com/user-interface/ios-5-customize-uinavigationbar-and-uibarbuttonitem-with-appearance-api.html#comment-109364