如果导航控制器的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. 谈谈C#中的接口

    接口的相关陈述 1.一个接口定义了一个契约. 2.接口可以包容方法.C#属性.事件.以及索引器. 3.在一个接口声明中,我们可以声明零个或者多个成员. 4.所有接口成员的默认访问类型都是public. ...

  2. [TypeScript] Inheritance

    Inheritance is a way toindicate that a class receives behavior from a parent class. Then we can over ...

  3. Percona Live 2016 PPT整理-zhaiwx_yinfeng

    https://yq.aliyun.com/articles/54454?spm=5176.100239.bloglist.32.CllwIr

  4. VS项目属性配置实验过程

    (原创,转载注明出处:http://www.cnblogs.com/binxindoudou/p/4017975.html ) 一.实验背景 cocos2d-x已经发展的相对完善了,从项目的创建.编译 ...

  5. Maven常用插件--转

    =========Maven Report Plugin========= 1.源码分析 <artifactId>maven-pmd-plugin</artifactId> 2 ...

  6. [转] C语言多维数组与多级指针

    http://c.biancheng.net/cpp/html/477.html 多维数组与多级指针也是初学者感觉迷糊的一个地方.超过二维的数组和超过二级的指针其实并不多用.如果能弄明白二维数组与二级 ...

  7. 新一代 PHP 加速插件 Zend Opcache <转>

    注: 由于原链接已不存在, 所以我把图片重新整理了一下, 以便看起来更加直观 笔者注: 1>  PHP 性能提升之 PHP NG  =>  php next generation wiki ...

  8. Ajax 如何提交集合到mvc后台

    1,前端请求如下 var apply = { CompanyName: $("[name='corpName']").val(), ContactUser: $("[na ...

  9. HTML案例练习一

    发现其实JS也是挺容易的,也挺好玩的,写的一个控制图片移动的小案例,对DOM机制还是不怎么熟. <html> <head> <style type = "tex ...

  10. javascript 实用函数

    1.去除字符串空格 /*去左空格*/ function ltrim(s) { return s.replace(/^(\s*| *)/, ""); } /*去右空格*/ funct ...