再次思考UINavgationBar的自定义问题
来源:互联网 发布:阿里云vps搭建ss教程 编辑:程序博客网 时间:2024/05/18 09:09
在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:viewControlleranimated:animated];
if (viewController.navigationItem.leftBarButtonItem==nil && [self.viewControllers count] >1) {
viewController.navigationItem.leftBarButtonItem =[selfcreateBackButton];
}
}
但是ios5时代这种做法是不行的,不过也有人找到了办法.http://blog.csdn.net/viktyz/article/details/7282925
其实最简单的办法,直接隐藏掉吧.自己在视图重新弄个bar就搞定了.何必那么啰嗦.
- 再次思考UINavgationBar的自定义问题
- 自定义UINavgationBar的高度
- iphone--自定义UINavgationBar
- 对++的再次思考
- 对++的再次思考
- 再次对于Matrix 的思考
- YUI, JavaScript 构造函数的再次思考
- log file sync的再次思考
- 关于模拟键盘的再次思考。
- 数据库的再次连接问题
- 自定义类型的思考
- 自定义类型的思考
- 关于自定义view的思考
- 再次探究复制问题的解法.
- 再次时配置jdk遇到的问题
- 再次配置windows caffe遇到的问题
- 值得思考的问题
- 宏观的思考问题
- Linux初始RAM磁盘介绍
- vss 编辑器或项目正在尝试签出在内存中修改的文件,这将导致保存改文件
- linux中的列编辑
- Linux 内核的主要工作
- Android检测电源状态
- 再次思考UINavgationBar的自定义问题
- curl 详解
- android.view.WindowManager$BadTokenException: Unable to add window -- token nul
- Android平台显示单位px和dip以及sp的区别
- Linux下的图形用户界面编程
- jquery cookie的用法
- discuz X2.5论坛数据搬家完美方法无缝迁移
- Android系统层次结构及分析
- 6.虚拟机字节码执行引擎