如果导航控制器的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. POJ 1417 True Liars

    题意:有两种人,一种人只会说真话,另一种人只会说假话.只会说真话的人有p1个,另一种人有p2个.给出m个指令,每个指令为a b yes/no,意思是,如果为yes,a说b是只说真话的人,如果为no,a ...

  2. 简单的闭包运算(Closure)演示程序

    /* * 该程序用于计算某个产生式的闭包 * RexfieldVon * 2013年8月9日16:01:38 */ #include <stdio.h> #include <stdl ...

  3. 用于A*的 二叉堆 AS3实现

    package com.copper.isometric.pathing {     import flash.sampler.startSampling;           /**      * ...

  4. Android之开发常用颜色

    Android开发中常常要用一些个性化的颜色,然而茫茫的RBG颜色对照表,往往给人眼花缭乱的感觉,更别说从中轻易选出一两种比较满意的颜色,下面我就总结一下开发中常用到的比较绚丽的颜色,都是有名有姓的哦 ...

  5. Meth | phpstorm invalid descendent file name

     Failed to collect files: Invalid descendent file name "codelog_ddz.\"(]))\",\').txt& ...

  6. Gradle Import Wizard--官方文档

    Last updated and checked to work with version 3.0.0 of the tools This tutorial will take you through ...

  7. RabbitMQ Management HTTP API--官方文档

    Introduction Apart from this help page, all URIs will serve only resources of type application/json, ...

  8. 【教训】rm -fr ./* 教训

    昨晚犯了一个重大错误,运行了 rm -rf ./* 本来是要删除一个不重要的目录的,结果在它的父目录下运行了上面命令,结果...都没了... 幸好数据库文件没有被删掉,数据还在,网站程序被删掉了,不久 ...

  9. Topcoder SRM 656 (Div.1) 250 RandomPancakeStack - 概率+记忆化搜索

    最近连续三次TC爆零了,,,我的心好痛. 不知怎么想的,这题把题意理解成,第一次选择j,第二次选择i后,只能从1~i-1.i+1~j找,其实还可以从j+1~n中找,只要没有被选中过就行... [题意] ...

  10. Codeforces Round #291 (Div. 2) C - Watto and Mechanism 字符串

    [题意]给n个字符串组成的集合,然后有m个询问(0 ≤ n ≤ 3·105, 0 ≤ m ≤ 3·105) ,每个询问都给出一个字符串s,问集合中是否存在一个字符串t,使得s和t长度相同,并且仅有一个 ...