Possible Duplicate:
How to add background image on iphone Navigation bar ?
iOS - How did the NY Times do this custom top navigation bar styling?
And for that matter, the bottom one?
@ludwigschubert's solution does however not work on iOS 5. Neither does overriding -drawRect:
, because it isn't even called.
As of iOS 5, a navigation bar consist of a UINavigationBarBackground
and a UINavigationItemView
. There are two other ways of getting it work.
Insert your custom image view at index 1 instead of 0. This makes it appear above the native background image while staying below the buttons.
Make use of iOS 5's UIAppearance protocol. You can either set the background image for all
[[UINavigationBar appearance] setBackgroundImage:myImage forBarMetrics:UIBarMetricsDefault]
or for just one navigation bar:
[navigationController.navigationBar setBackgroundImage:myImage forBarMetrics:UIBarMetricsDefault]
Make sure to provide two images (UIBarMetricsDefault & UIBarMetricsLandscapePhone) when developing an iPhone app for both portrait and landscape.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With