UI初级第五课  导航控制器——iOS学习连载20
2015-08-19 08:31
453 查看
1.RootViewController:让一个控制器作为导航控制器的根控制器
2.导航栏的高度是44,状态栏的高度是20
3.在iOS7之前,self.view的坐标是从(0,64)开始的,在ios7之后,导航栏和状态栏全部透明,仍旧是(0,0)开始
4.navigationController是每一个视图控制器(UIViewController)都有的属性,如果说该控制器被放在某个导航控制器中管理,则能够直接拿到这个导航控制器,如果没有放到导航控制器中管理,则此属性对象为nil
5.push到下一个控制器:self.navigationControllerpushViewController:secondVCanimated:true];
6.Pop回到上一级界面:[self.navigationControllerpopViewControllerAnimated:true];
7. 拿到所有的子控制器的个数并设置标题
NSInteger count =
self.navigationController.viewControllers.count;
self.title = [NSStringstringWithFormat:@"第%ld个控制器",
count];
8.一般在iOS6中我们经常自定义返回上一级的按钮,但在iOS7以后,如果自定义返回上一级的按钮,则系统的抽屉式导航手势失效
9.设置导航栏的风格
self.navigationController.navigationBar.barStyle
=UIBarStyleBlack;
10.设置导航栏不透明
self.navigationController.navigationBar.translucent = false;
11.设置导航栏颜色
self.navigationController.navigationBar.barTintColor = [UIColor redColor];
12.设置导航栏提示用户的内容(用得比较少)
self.navigationItem.prompt = @"hehehe";
13.设置导航栏title的字体的颜色,大小
self.navigationController.navigationBar.titleTextAttributes = @{NSFontAttributeName: [UIFont boldSystemFontOfSize:20],
NSForegroundColorAttributeName: [UIColor redColor]};
14.自定义导航栏上的按钮
UIButton*btn = [UIButtonbuttonWithType:UIButtonTypeCustom];
[btnsetBackgroundImage:[UIImageimageNamed:@"btn_search.png"]forState:UIControlStateNormal];
btn.frame=
CGRectMake(0,0,33,32);
UIBarButtonItem*item4 = [[UIBarButtonItemalloc]initWithCustomView:btn];
self.navigationItem.rightBarButtonItem
= item4;
15.设置项目全局的导航栏的背景颜色
//注意:所有带UI_APPEARANCE_SELECTOR宏修饰的方法都可以全局设置
[[UINavigationBarappearance]
setBackgroundImage:img
forBarMetrics:UIBarMetricsDefault];
16.设置项目全局的导航栏的title字体颜色和大小
[[UINavigationBarappearance]setTitleTextAttributes:@{NSFontAttributeName:
[UIFont
boldSystemFontOfSize:16],NSForegroundColorAttributeName:
[UIColorwhiteColor]}];
17.设置状态栏:设置pilit文件中的View
controller-based status bar appearance
设为NO
//通过全局application去修改
[[UIApplicationsharedApplication]
setStatusBarStyle:UIStatusBarStyleLightContent];
18.隐藏/显示状态栏
[[UIApplicationsharedApplication]
setStatusBarHidden:self.navigationController.navigationBarHiddenwithAnimation:UIStatusBarAnimationFade];
19.隐藏导航栏
[self.navigationControllersetNavigationBarHidden:!self.navigationController.navigationBarHiddenanimated:true];
2.导航栏的高度是44,状态栏的高度是20
3.在iOS7之前,self.view的坐标是从(0,64)开始的,在ios7之后,导航栏和状态栏全部透明,仍旧是(0,0)开始
4.navigationController是每一个视图控制器(UIViewController)都有的属性,如果说该控制器被放在某个导航控制器中管理,则能够直接拿到这个导航控制器,如果没有放到导航控制器中管理,则此属性对象为nil
5.push到下一个控制器:self.navigationControllerpushViewController:secondVCanimated:true];
6.Pop回到上一级界面:[self.navigationControllerpopViewControllerAnimated:true];
7. 拿到所有的子控制器的个数并设置标题
NSInteger count =
self.navigationController.viewControllers.count;
self.title = [NSStringstringWithFormat:@"第%ld个控制器",
count];
8.一般在iOS6中我们经常自定义返回上一级的按钮,但在iOS7以后,如果自定义返回上一级的按钮,则系统的抽屉式导航手势失效
9.设置导航栏的风格
self.navigationController.navigationBar.barStyle
=UIBarStyleBlack;
10.设置导航栏不透明
self.navigationController.navigationBar.translucent = false;
11.设置导航栏颜色
self.navigationController.navigationBar.barTintColor = [UIColor redColor];
12.设置导航栏提示用户的内容(用得比较少)
self.navigationItem.prompt = @"hehehe";
13.设置导航栏title的字体的颜色,大小
self.navigationController.navigationBar.titleTextAttributes = @{NSFontAttributeName: [UIFont boldSystemFontOfSize:20],
NSForegroundColorAttributeName: [UIColor redColor]};
14.自定义导航栏上的按钮
UIButton*btn = [UIButtonbuttonWithType:UIButtonTypeCustom];
[btnsetBackgroundImage:[UIImageimageNamed:@"btn_search.png"]forState:UIControlStateNormal];
btn.frame=
CGRectMake(0,0,33,32);
UIBarButtonItem*item4 = [[UIBarButtonItemalloc]initWithCustomView:btn];
self.navigationItem.rightBarButtonItem
= item4;
15.设置项目全局的导航栏的背景颜色
//注意:所有带UI_APPEARANCE_SELECTOR宏修饰的方法都可以全局设置
[[UINavigationBarappearance]
setBackgroundImage:img
forBarMetrics:UIBarMetricsDefault];
16.设置项目全局的导航栏的title字体颜色和大小
[[UINavigationBarappearance]setTitleTextAttributes:@{NSFontAttributeName:
[UIFont
boldSystemFontOfSize:16],NSForegroundColorAttributeName:
[UIColorwhiteColor]}];
17.设置状态栏:设置pilit文件中的View
controller-based status bar appearance
设为NO
//通过全局application去修改
[[UIApplicationsharedApplication]
setStatusBarStyle:UIStatusBarStyleLightContent];
18.隐藏/显示状态栏
[[UIApplicationsharedApplication]
setStatusBarHidden:self.navigationController.navigationBarHiddenwithAnimation:UIStatusBarAnimationFade];
19.隐藏导航栏
[self.navigationControllersetNavigationBarHidden:!self.navigationController.navigationBarHiddenanimated:true];
相关文章推荐
- UITouch触摸与手势
- iOS开发 自定义UICollectionViewLayout实现Masonry Layout
- UI中的表视图用法
- 关于UI的屏幕触控事件示例
- UVA-10689 Yet another Number Sequence (矩阵二分幂模板)
- DB 查询分析器 6.04 发布 ,本人为之撰写的相关技术文章达78篇
- Android API Guides –System Permissions
- BZOJ 1696 [Usaco2007 Feb]Building A New Barn新牛舍 数学
- UITextField 弹出键盘的外观(类型)设置
- Git Gui for Windows的建库、克隆(clone)、上传(push)、下载(pull)、合并
- 解题报告 之 HDU5301 Buildings
- HDOJ 5400 Arithmetic Sequence 暴力枚举
- UI基本控件
- easyui Droppable组件实现放置特效
- 自定义UITableViewCell 上的多个按钮点击事件处理
- 利用NStimer制作UILabel跑马灯效果
- 【3】工作队列queues
- LeetCode187——Repeated DNA Sequences
- hdu 5400 Arithmetic Sequence
- hdu5400--Arithmetic Sequence