iPhone Graphics-Setting Background image of a UINavigationBar (Works with iOS 5)

Опубликовано: 10 Март 2026
на канале: MilmersXcode
3,727
11

In this tutorial you will learn how to change the background image of a UINavigationBar in iOS 4 and iOS 5.

UINavigationBar Background Sizes:
• 640x88 pixels - For Retina
• 320x44 pixels - For Normal

Main Code:

//For iOS 4.3.2 or below
@implementation UINavigationBar (UINavigationBarCatagory)

(void)drawRect:(CGRect)rect
{
UIImage *navBGImage = [UIImage imageNamed:@"NavigationBar.png"];
[navBGImage drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}

//For iOS 5 or above:
if ([[[UIDevice currentDevice] systemVersion] intValue] GreaterThanSign= 5.0)
[self.navController.navigationBar setBackgroundImage:[UIImage imageNamed:@"NavigationBar.png"] forBarMetrics:UIBarMetricsDefault];

Previous Video:    • iPhone Graphics: Changing a Cells backgrou...  
Playlist:    • Setting iPhone Graphics  
Next Video:    • iPhone Graphics - Making a custom Navigati...  

Jan-marteens channel:    / jm11081996  
Jans video tutorial:    • Video  

Twitter:   / failcakeapps  
Apple Developer Center: http://developer.apple.com/devcenter/...
Website: http://failcake.webs.com/
Channel:    / milmersxcode