UINavigationBar设置背景图片

为UINavigatonBar增加如下Category:

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

如下实际代码:

//修改导航栏的图片

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

@implementation RootViewController

#pragma mark -
#pragma mark View lifecycle

- (void)viewDidLoad {
[super viewDidLoad];
  //修改导航栏的颜色
self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:0.31 green:0.64 blue:0.85 alpha:1.0];
...
}




posted @ 2011-10-12 15:11  Piosa  阅读(1817)  评论(0编辑  收藏  举报