在ios4时代的时候,我记得是可以重写drawrect的方法来替换背景图片的.
网上一搜还是有多介绍的,比如:http://www.cocoachina.com/bbs/read.php?tid=84025
另外替换返回按钮的方法,通过继承Navcontroller,在push的时候重新设定leftbuttionitem
如:
@implementation CustomNavigationController
@synthesize isLoading;
//替换返回按钮
- (void)popself {
if (isLoading) {
NSLog(@"still loading,stop pop view");
return;
}
[self popViewControllerAnimated:YES];
}
- (UIBarButtonItem*)createBackButton {
UIButton *btn_return=[UIButton buttonWithType:UIButtonTypeCustom];
[btn_return addTarget:self action:@selector(popself) forControlEvents:UIControlEventTouchUpInside];
[btn_return setBackgroundImage:[UIImage imageNamed:@"btn_return.png"] forState:UIControlStateNormal];
btn_return.frame=CGRectMake(0, 0, 27, 25);
UIBarButtonItem *bar_itemreturn=[[[UIBarButtonItem alloc] initWithCustomView:btn_return] autorelease];
return bar_itemreturn;
/*return [[UIBarButtonItem alloc]
initWithTitle:@"返回"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(popself)];*/
}
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
[super pushViewController:viewController animated:animated];
if (viewController.navigationItem.leftBarButtonItem== nil && [self.viewControllers count] > 1) {
viewController.navigationItem.leftBarButtonItem =[self createBackButton];
}
}
但是ios5时代这种做法是不行的,不过也有人找到了办法.http://blog.csdn.net/viktyz/article/details/7282925
其实最简单的办法,直接隐藏掉吧.自己在视图重新弄个bar就搞定了.何必那么啰嗦.