系统UINavigationController使用相关参考
代码中设置:
- self.navigationController.navigationBarHidden = YES;
- self.navigationController.toolbarHidden = NO;
下面根据不同的对象来介绍UINavigationController相关的一些类:
//UINavigationBar
好吧,到现在为止在使用UINavigationController的时候我是很少很少使用到UINavigationBar来进行相关设置的,很多的时候都是直接跳过self.navigationItem来管理的。不过在使用系统NavgationController的时候有些属性还是很有用的,记录下:
//UINavigationItem 通常情况下我们在某个视图控制器中会通过self.navigationItem来管理系统的UINavigationController中的导航栏中的内容,UINavigationItem下的很多属性都是很常会用到的:
- //titleTextAttributes(ios5.0以后可用)这是UINavigationBar的一个属性,通过它你可以设置title部分的字体、字号、阴影等
- @property(nonatomic,copy) NSDictionary *titleTextAttributes NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;
- //UINavigationBar的这个属性可以设置navigation的内容和其中的按钮的颜色
- @property(nonatomic,retain) UIColor *tintColor;
- 代码调用:
- NSDictionary *dict = [NSDictionary dictionaryWithObject:[UIColor redColor] forKey:UITextAttributeTextColor];
- self.navigationController.navigationBar.titleTextAttributes = dict;
- self.navigationItem.hidesBackButton = YES;
- self.navigationController.navigationBar.tintColor = [UIColor greenColor];
//UIToolbar 一般我们也都是没用这个系统的工具栏的,不过这里也列一下好了0.0 UIToolbar一些属性我们也基本没使用,差不多就看作是存放多个UIBarButtonItem的容器好了,同时也大多使用UIViewController的扩张属性toolbarItems来管理好了,直接跳过UIToolbar。 使用的时候先要设置显示工具栏,默认是隐藏的额,然后就可以加入多个UIBarButtonItem了,一般当UIButton使用好了
- @property(nonatomic,copy) NSString *title; //导航栏的标题
- @property(nonatomic,retain) UIView *titleView; //导航栏的自定义视图,设定之后title就没效果了
- @property(nonatomic,copy) NSString *prompt; //设置了这个属性值之后,导航栏会加高30,在导航栏标题上方显示该值
- @property(nonatomic,retain) UIBarButtonItem *leftBarButtonItem;//自定义导航栏的左按钮,默认是返回按钮
- @property(nonatomic,retain) UIBarButtonItem *rightBarButtonItem;//自定义导航栏的左按钮,默认是没有东西显示
- //代码示例如下
- self.navigationItem.title = @"Root"; //设置标题,其实效果和self.title = @"Root";差不多
- self.navigationItem.prompt =@"prompt test";
- //在导航栏中添加segment
- NSArray *array = [NSArray arrayWithObjects:@"12",@"34", nil];
- UISegmentedControl *segmentedController = [[UISegmentedControl alloc] initWithItems:array];
- segmentedController.segmentedControlStyle = UISegmentedControlSegmentCenter;
- [segmentedController addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];
- self.navigationItem.titleView = segmentedController;
- //左按钮
- UIBarButtonItem *leftButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(selectLeftAction:)];
- self.navigationItem.leftBarButtonItem = leftButton;
- //右按钮
- UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(selectRightAction:)];
- self.navigationItem.rightBarButtonItem = rightButton;
- //下面这两个属性设置可同时设置多个左、右按钮,设置方法和单个的差不多,只是先给归类到一个数组中;不过最好不要和设置单个的混合使用
- @property(nonatomic,copy) NSArray *leftBarButtonItems NS_AVAILABLE_IOS(5_0);//设置多个左按钮,从左往右排列
- @property(nonatomic,copy) NSArray *rightBarButtonItems NS_AVAILABLE_IOS(5_0);//设置多个左按钮,从右往左排列
- 代码示例:
- self.navigationItem.leftBarButtonItems = [NSArray arrayWithObjects:leftButton,leftButton1, nil];
- //代码示例:
- self.navigationController.toolbarHidden = NO;
- UIBarButtonItem *one = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:nil action:nil];
- UIBarButtonItem *two = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:nil action:nil];
- UIBarButtonItem *three = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:nil action:nil];
- UIBarButtonItem *four = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:nil action:nil];
- //这个可使UIBarButtonItem自适应排列
- UIBarButtonItem *flexItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
- [self setToolbarItems:[NSArray arrayWithObjects:flexItem, one, flexItem, two, flexItem, three, flexItem, four, flexItem, nil]];
系统UINavigationController使用相关参考的更多相关文章
- atitit.短信 验证码 破解 v3 p34 识别 绕过 系统方案规划----业务相关方案 手机验证码 .doc
atitit.短信 验证码 破解 v3 p34 识别 绕过 系统方案规划----业务相关方案 手机验证码 .doc 1. 手机短信验证码 vs 图片验证码 安全性(破解成本)确实要高一些1 1 ...
- 使用VIRTUALBOX安装ANDROID系统 | 图文教程 | 相关设置
使用VIRTUALBOX安装ANDROID系统 | 图文教程 | 相关设置 http://icaoye.com/virtualbox-run-android/
- Linux显示目前与过去登入系统的用户相关信息
Linux显示目前与过去登入系统的用户相关信息 youhaidong@youhaidong-ThinkPad-Edge-E545:~$ last youhaido pts/0 :0 Sat Jan 2 ...
- last 列出登入系统的用户相关信息
Linux last 命令介绍 功能说明:列出目前与过去登入系统的用户相关信息. 语法: last [-adRx][-f <记录文件>][-n <显示列数>][帐号名称. ...
- Linux系统运维相关的面试题 (问答题)
这里给大家整理了一些Linux系统运维相关的面试题,有些问题没有标准答案,希望要去参加Linux运维面试的朋友,可以先思考下这些问题. 一.Linux操作系统知识 1.常见的Linux发行版本都有 ...
- Linux系统之网络相关的命令
Linux系统之网络相关的命令 网络概述 网络:通过通信介质和通信设备 将分布不同地点的两台或多台计算机,经过相应的程序实现通信switch 交换机router 路由器网络的功能:数据通信:利用网络传 ...
- Android开发之深入理解Android 7.0系统权限更改相关文档
http://www.cnblogs.com/dazhao/p/6547811.html 摘要: Android 6.0之后的版本增加了运行时权限,应用程序在执行每个需要系统权限的功能时,需要添加权限 ...
- JAVA如何利用Swiger获取Linux系统电脑配置相关信息
最近开发java应用程序,涉及到获取Linux服务器相关配置的问题,特地网上搜寻了下,采用Swiger包可以直接获取,再次小结一下,以便于以后能方便使用,也便于其他童鞋们学习. 推荐大家参考链接:ht ...
- Dubbo -- 系统学习 笔记 -- 配置参考手册
Dubbo -- 系统学习 笔记 -- 目录 配置参考手册 <dubbo:service/> <dubbo:reference/> <dubbo:protocol/> ...
随机推荐
- Incompatible operand types DeptE and int 异常处理
Incompatible operand types DeptE and int 1.java不会运算到==的值,把==改为equals 2.java不会运算到eequals的值 把equals的改为 ...
- 个性二维码开源专题<替换定位点>
基础方法: ChangeFillShape //修改填充形状 ChangeFillShape(...) // 摘要: // 修改填充形状 // // 参数: // g: // 图形画板 // // F ...
- ASP.NET MVC学习之Ajax(完结)
一.前言 通过上面的一番学习,大家一定收获不少.但是总归会有一个结束的时候,但是这个结束也意味着新的开始. 如果你是从事ASP.NET开发,并且也使用了第三方控件,那么一定会觉得ASP.NET开发aj ...
- 通信服务器群集——跨服务器通信Demo(源码)
对于一些基于TCP Socket的大型C/S应用来说,能进行跨服务器通信可能是一个绕不开的功能性需求.出现这种需求的场景类似于下面描述的这种情况. 假设,我们一台TCP应用服务器能同时承载10000人 ...
- unity3d——自带寻路Navmesh (三)(转)
继续介绍NavMesh寻路的功能,接下来阿赵打算讲一下以下两个例子,先看看完成的效果: 第一个例子对于喜欢DOTA的朋友应该很熟悉了,就是不同小队分不同路线进攻的寻路,红绿蓝三个队伍分别根据三条路 ...
- HTTP权威指南阅读笔记一:HTTP概述
HTTP协议版本: 1.HTTP/0.9:HTTP的1991原型版本称为HTTP/0.9.这个协议有很多严重的缺陷,只应该用与与老客户端的交互.HTTP/0.9只支持GET方法,不支持多媒体内容的MI ...
- Nutz Dao实体中索引注解的使用(@TableIndexes@Index)
Nutz是一组轻便小型的框架的集合, 各个部分可以被独立使用,把SSH的精华封装在一个1M左右的jar包中,Nutz不对其他任何第三方库产生依赖,如果不考虑数据库链接和日志的话,创建完美的Web应用只 ...
- RAR和ZIP:压缩大战真相
转:http://fqd2eh4y.blog.163.com/blog/static/69195855200801035015857 前言--王者归来? 等待足足两年之久,压缩霸主WinZip终于在万 ...
- Asset Catalog Help (二)---Creating an Asset Catalog
Creating an Asset Catalog Create an asset catalog to simplify management of your app’s images. 创建一个a ...
- WindowsPhone8拍照功能实现简介
WindowsPhone作为一款智能手机操作系统,支持APP中拍照是必不可少的,目前在WP8上的拍照主要有以下三种途径: 1.使用CameraCaptureTask: 2.使用PhotoCamera类 ...