Here is the code from. Paste this code into the rootview controller above @implementation rootviewController
@implementation UINavigationBar (CustomImage) - (void)drawRect:(CGRect)rect { UIImage *image = [UIImage imageNamed:@"NavigationBar.png"]; [image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)]; } @end
Like iOS 5, there is an official way to do this. (see iOS Developer Library )
// someplace where you create the UINavigationController if ([navigationController.navigationBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)] ) { UIImage *image = [UIImage imageNamed:@"NavigationBar.png"]; [navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault]; }
But still keep the old code for backward compatibility if you really don't want to cut iOS 4 and below.
iwat Dec 04 '09 at 14:18 2009-12-04 14:18
source share