Share on Google+Share on Google+

Background Image for Navigation Bar

Advertisement
The tutorial illustrates how to add background image for UINavigationBar.

Background Image for Navigation Bar

The tutorial illustrates how to add background image for UINavigationBar.

To add a background image to UINavigationBar, you need to create a category that extends UINavigationBar. Just find the below given code and add it into your implementation file.

@implementation UINavigationBar (CustomImage)
- (void)drawRect:(CGRect)rect {
UIImage *image = [UIImage imageNamed: @"background.png"];
[image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}
@end

After implementing it.. you can call it anywhere within your application and you can see the change on every view. Do not forget to add image into your resources folder.

Just build your application and it must look like as given output...

Download Code

Advertisements

Posted on: April 20, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.