本文主要是介绍ios 的navigationBar,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
在项目开发中常常会遇到各种奇葩的需求,尤其是要修改系统的按钮的时候。
这里我总结一下平时修改过的导航条的item,自定义的item
1. 页面title设置:self.title =@"Feebback";
2.返回按钮的修改:方案一:self.navigationItem.backBarButtonItem.title = @"Cancel";//这句话在该页面调用即可
如果方案一不能:则需要在前一个页面之前调用下面的方法:
self.navigationItem.backBarButtonItem=[[UIBarButtonItem alloc] initWithTitle:@"Back"style:UIBarButtonItemStyleBordered target:nil action:nil];
[self.navigationController pushViewController:controller animated:YES];
3.(1)定义leftItem or rightItem:
UIButton *button = [UIButtonbuttonWithType:UIButtonTypeCustom];
UIImage *image = [UIImageimageNamed:@"Image_Nearby_Filter_Icon"];
button.frame =CGRectMake(0,0, kScreenWidth/4, image.size.height);
[button setImageEdgeInsets:UIEdgeInsetsMake(0,60, 0,0)];
[button setImage:imageforState:UIControlStateNormal];
[button addTarget:selfaction:@selector(filterItemPressed)forControlEvents:UIControlEventTouchDown];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItemalloc]initWithCustomView:button];
(2)使用系统的item:
UIBarButtonItem *moreItme = [[UIBarButtonItemalloc] initWithImage:[UIImageimageNamed:@"Image_Me_Nav_Icon_More"]style:UIBarButtonItemStyleBorderedtarget:self
action:@selector(moreItemPressed:)];
self.navigationItem.rightBarButtonItem = moreItme;
其他的在以后遇到再继续补充这篇关于ios 的navigationBar的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!