系统UINavigationController使用相关参考
代码中设置:
self.navigationController.navigationBarHidden = YES;
self.navigationController.toolbarHidden = NO;
下面根据不同的对象来介绍UINavigationController相关的一些类:
//UINavigationBar
好吧,到现在为止在使用UINavigationController的时候我是很少很少使用到UINavigationBar来进行相关设置的,很多的时候都是直接跳过self.navigationItem来管理的。不过在使用系统NavgationController的时候有些属性还是很有用的,记录下:
//titleTextAttributes(ios5.0以后可用)这是UINavigationBar的一个属性,通过它你可以设置title部分的字体、字号、阴影等//UINavigationItem 通常情况下我们在某个视图控制器中会通过self.navigationItem来管理系统的UINavigationController中的导航栏中的内容,UINavigationItem下的很多属性都是很常会用到的:
@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];
@property(nonatomic,copy) NSString *title; //导航栏的标题//UIToolbar 一般我们也都是没用这个系统的工具栏的,不过这里也列一下好了0.0 UIToolbar一些属性我们也基本没使用,差不多就看作是存放多个UIBarButtonItem的容器好了,同时也大多使用UIViewController的扩张属性toolbarItems来管理好了,直接跳过UIToolbar。 使用的时候先要设置显示工具栏,默认是隐藏的额,然后就可以加入多个UIBarButtonItem了,一般当UIButton使用好了
@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/> ...
随机推荐
- 学习WPF——元素绑定
概念 从源对象提取一些信息,并用这些信息设置目标对象的属性 示例 在给TextBlock控件的FontSize属性赋值时,我们使用了绑定表达式 数据绑定表达式使用XAML的标记扩展(因此具有花括号)( ...
- [Java Web整合开发王者归来·刘京华] 2、 Java Web开发概述
1.Web相关概念 1-1.胖客户与瘦客户 >_<" RCP的定义及优缺点: >_<"TCP的定义及优缺点: 1-2.B ...
- [WinAPI] API 13 [遍历指定目录 打印文件和其他属性]
Windows API中,有一组专门的函数和结构,用于遍历目录,它们是FindFirstFile函数.FindNextFile函数和WIN32_FIND_DATA结构.使用FindFirstFile和 ...
- JQuery文本框水印插件的简单实现
采用JQuery实现文本框的水印效果非常容易,效果如下: 代码片段,定义要应用水印效果的文本框的样式: .watermark { color: #cccccc; } 将JavaScript代码封装成J ...
- 无线客户端框架设计(5):调用MobileAPI的设计(iOS篇)
这一节讲如何发起网络请求. iOS用于调用MobileAPI的第三方组件很多,我们这里采用的是以下组件: 1)ASIHTTPRequest,用于请求MobileAPI:http://allseeing ...
- jQuery Ztree基本用法
1.首先在页面上有<ul/>标签 <ul id="tree" class="ztree"></ul> 2.定义ztree的配 ...
- JProfiler使用详细教程学习笔记
JProfiler学习笔记 推荐文章:JProfiler 入门教程 一.安装JProfiler 从http://www.ej-technologies.com/下载5.1.2并申请 ...
- paip.快捷方式分组管理最佳实践ObjectDock
paip.快捷方式分组管理最佳实践ObjectDock /////挑选:除了od,还有个Berokyo ,但是bk无crash..只能使用1月.. Jumplist_Launcher_v7.2_rep ...
- Leetcode 202 Happy Number 弗洛伊德判环解循环
今天先谈下弗洛伊德判环,弗洛伊德判环原来是在一个圈内有两人跑步,同时起跑,一人的速度是另一人的两倍,则那个人能在下一圈追上另一个人,弗洛伊德判环能解数字会循环出现的题,比如说判断一个链表是不是循环链表 ...
- css之属性部分
这篇写的是今天的学习到的属性,一共20个. 属性再多,但也要会使用,会在使用时可以记起它,才能起到它为我们所需要的作用. 样式属性 1.border CSS边框属性允许你指定一个元素边框的样式和颜色. ...