Background Image for Navigation Bar


 

Background Image for Navigation Bar

The tutorial illustrates how to add background image for UINavigationBar.

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

Ads