Possible Duplicate:
How to add background image on iphone Navigation bar?
I am looking for a way to have a custom navigation bar and need to have a custom navigation bar background to achieve this. I was looking around for how to do this, but could not find a solution. If anyone has the solution, help is much appreciated.
(supplemental to Andrew Johnson's response)
The linked Apple.com post includes 3 or 4 different solutions, most of which only "half" work. I think the most elegant/effective of them is this one:
HOWEVER ... it's not good-practice ObjC to od that as a category (should be an override), and it has some problems of its own.
So, a more general and powerful solution is here:
http://samsoff.es/posts/customize-uikit-with-method-swizzling
Copy this into viewDidLoad. It will check for iOS 5 and use the preferred method, otherwise it will add a subview to the navBar for iOS versions < 5.0. This will work provided that your custom background image has no transparencies.
You can just add a subview (a UIImageView) to the navaigationBar, which is just a UIView subclass.
Here's a forum post that describes how to wrap this up into a category: http://discussions.apple.com/thread.jspa?threadID=1649012&tstart=0
Since iOS5, you can easily set a custom background, with the method setBackgroundImage:forBarMetrics: But you must check if the user's phone has the right OS.
This is a nicer solution, cause it's in the doc.