如果导航控制器的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的更多相关文章

  1. 转发-UI基础教程 – 原生App切图的那些事儿

    UI基础教程 – 原生App切图的那些事儿 转发:http://www.shejidaren.com/app-ui-cut-and-slice.html 移动APP切图是UI设计必须学会的一项技能,切 ...

  2. Android UI基础之五大布局

    Android  UI基础之五大布局 Android的界面是有布局和组件协同完成的,布局好比是建筑里的框架,而组件则相当于建筑里的砖瓦.组件按照布局的要求依次排列,就组成了用户所看见的界面.Andro ...

  3. iOS开发UI基础—手写控件,frame,center和bounds属性

    iOS开发UI基础—手写控件,frame,center和bounds属性 一.手写控件 1.手写控件的步骤 (1)使用相应的控件类创建控件对象 (2)设置该控件的各种属性 (3)添加控件到视图中 (4 ...

  4. Android UI基础教程 目录

    从csdn下载了这本英文版的书之后,又去京东搞了一个中文目录下来.对照着看. 话说,这本书绝对超值.有money的童鞋看完英文版记得去买中文版的~~ Android UI基础教程完整英文版 pdf+源 ...

  5. UI基础UIButton

    UI基础UIButton 前面写了UIWindow.UIViewController,那些都是一些框架,框架需要填充上具体的view才能组成我们的应用,移动应用开发中UI占了很大一部分,最基础的UI实 ...

  6. UI基础UIWindow、UIView

    UI基础UIWindow.UIView 在PC中,应用程序多是使用视窗的形式显示内容,手机应用也不例外,手机应用中要在屏幕上显示内容首先要创建一个窗口承载内容,iOS应用中使用UIWindow.UIV ...

  7. IOS开发UI基础--数据刷新

    IOS开发UI基础--数据刷新 cell的数据刷新包括下面几个方面 加入数据 删除数据 更改数据 全局刷新方法(最经常使用) [self.tableView reloadData]; // 屏幕上的全 ...

  8. Android 的UI基础布局的学习

    一. 今天学习了Android 的UI基础布局的部分,绝大多数的布局都在Androidstudio的这个界面里,如下: 在左边的框里的palette的内部,包含了的大多数的布局所要用的button按钮 ...

  9. iOS UI基础-11.0 UINavigationController

    导航控制器 利用UINavigationController,可以轻松地管理多个控制器,轻松完成控制器之间的切换,典型例子就是系统自带的“设置”应用 UINavigationController的使用 ...

随机推荐

  1. SRM 597

    我果然是题短了就能做得好- -.Div 2的三道题都短,于是迅速的过掉了250和500,rating涨了150^ ^. Div 2 250pt 题意:给一个vector<int> A,对其 ...

  2. Jenkins 九: 小技巧

    1.  问题: jenkins的项目默认存放在 JENKINS_HOME下面的 workspace路径下,导致每次找项目都很不方便. 解决思路:更改jenkins的项目存放地址. 解决方法: 1) 将 ...

  3. poj2393

    题目大意: 奶酪工厂 奶牛买了一个奶酪工厂制作全世界有名的Yucky酸奶,在接下来的N周(1<=N<=10000),牛奶的价格和工作将会受到波动例如他将花费C_i (1 <= C_i ...

  4. oracle权限问题

    Assign the "Create global objects" user right to the non-Administrator account. 1. Click S ...

  5. 使用Java Mail发送邮件

    本笔记参考自:高爽|Coder,原文地址:http://blog.csdn.net/ghsau/article/details/17839983 JavaMail是SUN提供给开发人员在应用程序中实现 ...

  6. Hard 随机洗牌函数 @CareerCup

    第i个元素和index在[i,length-1]之间的一个数随机交换 package Hard; import CtCILibrary.AssortedMethods; /** * * Write a ...

  7. 全文检索luncence

    检索技术基本原理: 最主要的两点是  1.如何创建索引 2.如何查询.  分析需求: 好几篇文档,从这些文档找关键词,一种方式是顺序一个个遍历,加入这些文档量很多,就花费太长时间了,第二种是建立索引, ...

  8. .NET常用的扩展方法整理

    using System; using System.Collections; using System.Collections.Generic; using System.Data; using S ...

  9. Json序列化、反序列化互换

    // 序列化 using (MemoryStream stream = new MemoryStream()) { serializer.WriteObject(stream, hdm); jsonT ...

  10. dede 留言簿 多个

    使用后台的[模块]-[模块生成向导],然后填写一下资料 PS:complaints 是之前做的一个"举报投诉"的留言簿意思,这里用作非常多文件名称和新建数据表的名字,所以替换就可以 ...