系统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/> ...
随机推荐
- 注册表(regedit)
注册表(Registry,繁体中文版Windows称之为登录档)是Microsoft Windows中的一个重要的数据库,用于存储系统和应用程序的设置信息. 打开方式:1.开始>>运行.中 ...
- SQLSERVER truncate table之后是否会重置表的自增值
SQLSERVER truncate table之后是否会重置表的自增值 今天清理业务库数据的时候,开发人员说可以使用truncate table把两个表的所有数据清理掉 这两个表都有自增ID,都做了 ...
- 设计模式->观察者模式
观察者模式能非常大的减少模块之前的耦合.具体的观察者模式,客官们可以去看<设计模式>或者<Head first设计模式>等之类的书. 在java中,java.util库中封装了 ...
- IHttpActionResult – new way of creating responses in ASP.NET Web API 2
先收藏这篇文章. http://www.strathweb.com/2013/06/ihttpactionresult-new-way-of-creating-responses-in-asp-net ...
- 客户端缓存 HTML + 远程数据 JS 的思路。
移动客户端,采用客户端集成 WebBrowser 的方式 ,加载远程网页的优化方案. 1. 远程 HTML版本 v1.2 一次性加载到客户端 2. 手机端打开时,检测HTML版本. 如果有新版,先更新 ...
- C/C++文件操作2
一.流式文件操作 这种方式的文件操作有一个重要的结构FILE,FILE在stdio.h中定义如下: typedef struct { int level; /* fill/empty level of ...
- 【系统移植】JNI
jni代码 java调用jni的接口: 1, 调用动态库 static{ System.loadLibrary("led_jni"); // system/lib/lible ...
- Django基础——Model篇(三)
一 Django ORM中的概念 ORM —— 关系对象映射,是Object Relational Mapping的简写,是用来简化数据库操作的框架 Django ORM遵循Code Frist原则, ...
- 使用 Aircrack-ng 破解 WEP 和 WPA/WPA2 加密的 Wi-Fi 密码。(转)
1.首先请不要使用此方法去搞破坏,去蹭Wi-Fi,因为不装逼地说,我认为技术本身的价值很大,尤其是在学习这个技术的过程中解决遇到的问题,当经过重重困难最后终于成功之后的喜悦又怎么能拿去蹭网呢.我在此过 ...
- centos7防火墙那些事
转发设置 firewall-cmd --permanent --add-forward-port=port=80:proto=tcp:toport=8080 firewall-cmd --perma ...