IOS 自定义导航栏标题和返回按钮标题
2016-01-27 14:01
435 查看
IOS中自定义导航栏标题:
UILabel *titleText = [[UILabel alloc] initWithFrame: CGRectMake(160, 0, 120, 50)]; titleText.backgroundColor = [UIColor clearColor]; titleText.textColor=[UIColor whiteColor]; [titleText setFont:[UIFont systemFontOfSize:17.0]]; [titleText setText:@"XXX"]; self.navigationItem.titleView=titleText; [titleText release];
IOS中自定义导航栏返回按钮:(放在pushViewController之前)
UIBarButtonItem *backItem=[[UIBarButtonItem alloc]init]; backItem.title=@"后退"; backItem.tintColor=[UIColor colorWithRed:129/255.0 green:129/255.0 blue:129/255.0 alpha:1.0]; self.navigationItem.backBarButtonItem = backItem; [backItem release];
IOS中自定义导航栏右边按钮:
UIBarButtonItem * rightButton = [[UIBarButtonItem alloc] initWithTitle:@"回到首页" style:UIBarButtonItemStyleBordered target:self action:@selector(callModalList)]; rightButton.image=[UIImage imageNamed:@"right_button.png"]; rightButton.tintColor=[UIColor colorWithRed:74/255.0 green:74/255.0 blue:74/255.0 alpha:1.0]; self.navigationItem.rightBarButtonItem = rightButton; [rightButton release];
或者
//设置返回按钮 UIButton* backButton = [UIButton buttonWithType:UIButtonTypeCustom]; [backButton setBackgroundImage:[UIImage imageNamed:@"btn_public_back"] forState:UIControlStateNormal]; backButton.frame = CGRectMake(0, 0, 35,35); [backButton addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside]; leftBarItem = [[UIBarButtonItem alloc] initWithCustomView:backButton]; self.navigationItem.leftBarButtonItem = leftBarItem;
相关文章推荐
- iOS objc_msgSend报错问题
- 1.CocoaPods的安装
- IOS平台各种解析XML库的优缺点分析
- HDU 1017 A Mathematical Curiosity
- iOS 时间间隔计算
- iOS中MVVM理解
- iOS设置textView的placeholder
- IOS笔记
- iOS 设置文本中指定某段文本的颜色 大小
- IOS中对于多个按钮,选中其中一个,其他按钮选中状态为NO
- iOS设置textView的行间距
- ios开发-格式转换
- iOS开发-修改TableViewCell的Delete按钮
- iOS统计数组相同元素的个数(使用数组筛选计算)
- [iOS]修改开发者中心Bundle Identifier的一些配置
- iOS 视图左右晃动动画
- iphone ios 如何使用gcd,block
- iOS中的协议与委托
- iOS开发-进阶:企业级应用Plist文件模板
- iOS开发-工具:Xcode7 做ipa企业级分发(In-House模式)详细步骤