@implementation UINavigationBar (CustomImage)
- (void)drawRect:(CGRect)rect {
UIImage *image = [UIImage imageNamed: @"title.png"];
[image drawInRect:CGRectMake(0, 0, self.frame.size.width,self.frame.size.height)];
}
@end
@implementation HXNavigationController
- (id)initWithRootViewController:(UIViewController *)rootViewController
{
self = [super initWithRootViewController:rootViewController];
if (self) {
#if defined(__IPHONE_5_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_5_0
float version = [[[UIDevice currentDevice] systemVersion] floatValue];
if (version >= 5.0)
{
if ([self.navigationBar respondsToSelector:@selector( setBackgroundImage:forBarMetrics:)]){
[self.navigationBar setBackgroundImage:[UIImage imageNamed:@"title.png"] forBarMetrics:UIBarMetricsDefault];
}
}
#endif
}
return self;
}
自定义navigation bar 支持iOS5以及iOS5以下版本的代码
最新推荐文章于 2022-02-11 16:41:27 发布