xcode5--ios7自定义导航栏标题、按钮(随笔)
2014-03-17 15:20
127 查看
一、自定义标题:
二、自定义返回按钮
三、自定义右侧按钮
UILabel *titleText = [[UILabel alloc] initWithFrame: CGRectMake(100, 0, 180, 50)]; titleText.backgroundColor = [UIColor clearColor]; titleText.textColor=[UIColor whiteColor]; titleText.textAlignment=UITextAlignmentCenter; [titleText setFont:[UIFont systemFontOfSize:17.0]]; [titleText setText:@"选择模式"]; self.navigationItem.titleView=titleText;
二、自定义返回按钮
//自定义返回 UIButton *backBtn = [[UIButton alloc] initWithFrame:CGRectMake(0.0, 100.0, 49.0, 29.0)]; [backBtn setBackgroundImage:[UIImage imageNamed:@"上导航-左返回.png"] forState:UIControlStateNormal]; [backBtn.titleLabel setFont:[UIFont fontWithName:@"Helvetica" size:12]]; [backBtn addTarget:self action:@selector(backOff:) forControlEvents:UIControlEventTouchUpInside]; UIBarButtonItem *backButtonItem=[[UIBarButtonItem alloc] initWithCustomView:backBtn]; self.navigationItem.leftBarButtonItem = backButtonItem;
三、自定义右侧按钮
//自定义下一步按钮 UIButton *rightBtn = [[UIButton alloc] initWithFrame:CGRectMake(0.0, 100.0, 49.0, 29.0)]; [rightBtn setBackgroundImage:[UIImage imageNamed:@"上导航-按钮.png"] forState:UIControlStateNormal]; [rightBtn setTitle:@"下一步" forState:UIControlStateNormal]; [rightBtn.titleLabel setFont:[UIFont boldSystemFontOfSize:13]]; [rightBtn addTarget:self action:@selector(nextStep:) forControlEvents:UIControlEventTouchUpInside]; UIBarButtonItem *rightButtonItem=[[UIBarButtonItem alloc] initWithCustomView:rightBtn]; self.navigationItem.rightBarButtonItem = rightButtonItem;
相关文章推荐
- Swift- 自定义导航栏背景、标题和返回按钮属性
- 自定义导航栏按钮 标题
- IOS 自定义导航栏标题和返回按钮标题
- IOS自定义导航按钮和标题
- 自定义导航栏返回按钮backBarButtonItem的标题
- iOS 自定义导航栏标题和按钮
- iOS 获取当前日期和星期几,改变导航系统返回按钮的标题
- IOS 自定义导航栏标题和返回按钮标题
- ios之自定义导航栏背景,标题和返回按钮文字颜色
- IOS 自定义导航栏题目和返回按钮标题
- IOS 自定义导航栏标题和返回按钮标题
- IOS 自定义导航栏题目和返回按钮标题
- iOS 7+自定义导航栏背景,标题和返回按钮文字颜色
- IOS 自定义导航栏标题和返回按钮标题
- iOS 自定义导航栏背景,左侧按钮,右侧按钮,及标题
- iOS自定义导航栏标题和返回按钮标题
- android4.0屏蔽导航按钮的方法
- bootstrap菜单、按钮及导航学习笔记5-2
- bootstrap菜单、按钮及导航学习笔记5-18导航(基础样式)
- IOS开发中如何自定义导航栏的按钮,文字和背景图片