Home Tutorial Iphone Examples Background Image for Navigation Bar

 
 

Background Image for Navigation Bar
Posted on: April 20, 2010 at 12:00 AM
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

Related Tags for Background Image for Navigation Bar:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.