UI基础 - UINavigationController
如果导航控制器的BarButtonItem属性是一致的,可以重写initialize方法用来设置主题
//再ViewDidload执行前只执行一次
+(void)initialize
{
//创建的UIBarButtonItem的属性会从这里获取
UIBarButtonItem *appearance = [UIBarButtonItem appearance];
//普通情况下
NSMutableDictionary *nor = [NSMutableDictionary dictionary];
nor[NSForegroundColorAttributeName] = [UIColor orangeColor];
nor[NSFontAttributeName] = [UIFont systemFontOfSize:15];
[appearance setTitleTextAttributes:nor forState:UIControlStateNormal];
//高亮情况下
NSMutableDictionary *high = [NSMutableDictionary dictionaryWithDictionary:nor];
high[NSForegroundColorAttributeName] = [UIColor greenColor];
[appearance setTitleTextAttributes:high forState:UIControlStateHighlighted];
//不可以点击情况下
NSMutableDictionary *disable = [NSMutableDictionary dictionaryWithDictionary:nor];
disable[NSForegroundColorAttributeName] = [UIColor grayColor];
[appearance setTitleTextAttributes:disable forState:UIControlStateDisabled];
/**设置背景**/
// 技巧: 为了让某个按钮的背景消失, 可以设置一张完全透明的背景图片
// [appearance setBackgroundImage:[UIImage imageNamed:@"navigationbar_button_background"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
}
也可以一次性设置leftBarButtonItem和rightBarButtonItem
重写
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated;
-(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
/*这里传进来的是navController,
self.viewControllers.count代表nav栈里控制器的数量,如果大于0,那就不是栈低控制器
也就不是最开始看到的四个
*/
if(self.viewControllers.count > 0 ){
viewController.hidesBottomBarWhenPushed = YES;
viewController.navigationItem.leftBarButtonItem = [UIBarButtonItem initWithImage:@"navigationbar_back" HighImage:@"navigationbar_back_highlighted" action:@selector(back) target:self];
viewController.navigationItem.rightBarButtonItem = [UIBarButtonItem initWithImage:@"navigationbar_more" HighImage:@"navigationbar_more_highlighted" action:@selector(more) target:self];
}
[super pushViewController:viewController animated:YES];
}
UI基础 - UINavigationController的更多相关文章
- 转发-UI基础教程 – 原生App切图的那些事儿
UI基础教程 – 原生App切图的那些事儿 转发:http://www.shejidaren.com/app-ui-cut-and-slice.html 移动APP切图是UI设计必须学会的一项技能,切 ...
- Android UI基础之五大布局
Android UI基础之五大布局 Android的界面是有布局和组件协同完成的,布局好比是建筑里的框架,而组件则相当于建筑里的砖瓦.组件按照布局的要求依次排列,就组成了用户所看见的界面.Andro ...
- iOS开发UI基础—手写控件,frame,center和bounds属性
iOS开发UI基础—手写控件,frame,center和bounds属性 一.手写控件 1.手写控件的步骤 (1)使用相应的控件类创建控件对象 (2)设置该控件的各种属性 (3)添加控件到视图中 (4 ...
- Android UI基础教程 目录
从csdn下载了这本英文版的书之后,又去京东搞了一个中文目录下来.对照着看. 话说,这本书绝对超值.有money的童鞋看完英文版记得去买中文版的~~ Android UI基础教程完整英文版 pdf+源 ...
- UI基础UIButton
UI基础UIButton 前面写了UIWindow.UIViewController,那些都是一些框架,框架需要填充上具体的view才能组成我们的应用,移动应用开发中UI占了很大一部分,最基础的UI实 ...
- UI基础UIWindow、UIView
UI基础UIWindow.UIView 在PC中,应用程序多是使用视窗的形式显示内容,手机应用也不例外,手机应用中要在屏幕上显示内容首先要创建一个窗口承载内容,iOS应用中使用UIWindow.UIV ...
- IOS开发UI基础--数据刷新
IOS开发UI基础--数据刷新 cell的数据刷新包括下面几个方面 加入数据 删除数据 更改数据 全局刷新方法(最经常使用) [self.tableView reloadData]; // 屏幕上的全 ...
- Android 的UI基础布局的学习
一. 今天学习了Android 的UI基础布局的部分,绝大多数的布局都在Androidstudio的这个界面里,如下: 在左边的框里的palette的内部,包含了的大多数的布局所要用的button按钮 ...
- iOS UI基础-11.0 UINavigationController
导航控制器 利用UINavigationController,可以轻松地管理多个控制器,轻松完成控制器之间的切换,典型例子就是系统自带的“设置”应用 UINavigationController的使用 ...
随机推荐
- redis合库
玩家数据全部保存在redis,对合服来绝对是个坑.因为一直都是做开发,合库这事还是第一次操作. 首先,合服要做哪些事情,当然不同的游戏肯定不一样.合服的目的是为了增加同个服务器上活跃玩家的数量.合服有 ...
- Linus:为何对象引用计数必须是原子的
Linus大神又在rant了!这次的吐槽对象是时下很火热的并行技术(parellism),并直截了当地表示并行计算是浪费所有人时间(“The whole “let’s parallelize” thi ...
- zookeeper 集群 Cannot open channel to X at election address Error contacting service. It is probably not running.
zookeeper集群 启动 1.问题现象. 启动每一个都提示 STARTED 但是查看 status时全部节点都报错 [root@ip-172-31-19-246 bin]# sh zkSer ...
- sql server 常用小知识点
1. sql server的语法:中文要加 N select * from eVA_EMPBoard where name = N'施纪平' 而oracle的不用 2.
- Xcode7连接网络设置
XCode7连接互联网的时候需要再info.plist设置(之前版本都不需要)连接网络NSAppTransportSecurity 字典NSAllowsArbitraryLoads 布尔 Y ...
- [Firebase] Deploy you website to Firebase
If you are looking for a host website, you can try Firebase, heroku or AWS... Today, I tried to depl ...
- Cocos2d-x 3.0 实例学习教程 前沿
前一段时间学过cocos2d-x 2.x ,后来去做了一些别的项目.近期又想开发自己的游戏了,但是cocos2d-x 已经升级到3.0 ,好多API都变了.所以决定再把cocos2d-x学一遍,一是 ...
- Getting Started with the NDK
The Native Development Kit (NDK) is a set of tools that allow you to leverage C and C++ code in your ...
- HeaderViewListAdapter
该类其实就是普通使用的Adapter的一个包装类,就是为了添加header和footer而定义的.该类一般不直接使用,当ListView有header和footer时,ListView中会自动把Ada ...
- python3下的super()
大家都知道super是用来解决python钻石多重继承出现的基类重复调用的问题,这个就不赘述了,不了解的请点击. 但是我发现还有个问题在于不是钻石继承时继承先后顺序的问题,也就是如果mixin与继承的 ...