IOS-自定义navigationBar,设置背景方法:

自定义的navigationBar,设置背景方法:
IOS 5.0以前的设备添加:
@implementation UINavigationBar (CustomImage)  
- (void)drawRect:(CGRect)rect {  
    UIImage *image = [UIImage imageNamed: @"add_nav_bg_ipad.png"];  
    [image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];  
}
@end
IOS 5.0 以后的设备再添加:
在viewdidLoad中增加:
if ([self.navgationBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)]) {
        [self.navgationBar setBackgroundImage:[UIImage imageNamed:@"add_nav_bg_ipad.png"] forBarMetrics:UIBarMetricsDefault];
    }

posted on 2012-06-29 16:59  tx天翔  阅读(2511)  评论(0编辑  收藏  举报