1.常用属性
viewControllers //所有在栈中的控制器
topViewController //栈顶控制器
navigationBar //导航栏 竖屏下默认44,横屏默认32

2.对navigationBar的标题进行字体颜色等设置
NSDictionary *dic = @{
NSForegroundColorAttributeName:[UIColor whiteColor]
};
UIViewController.navigationBar.titleTextAttributes = dic;

3.navigation返回的设置
使用pushViewController切换到下一个视图时,navigation controller按照以下3条顺序更改导航栏的左侧按钮。

(1)、如果B视图有一个自定义的左侧按钮(leftBarButtonItem),则会显示这个自定义按钮;

(2)、如果B没有自定义按钮,但是A视图的backBarButtonItem属性有自定义项,则显示这个自定义项;

(3)、如果前2条都没有,则默认显示一个后退按钮,后退按钮的标题是A视图的标题()

4.自定义navigationBar
navigationController.navigationBar.barTintColor //导航条颜色
[navigationController.navigationBar setBackgroundImage] //导航条加背景

5.管理UINavigationItem
UINavigationBar处理能管理一组UINavigationItem

与UINavigationController相似,UINavigationBar也是以栈的方式管理一组UINavigationItem。提供push和pop操作item

每个视图控制器都有一个navigationItem属性,navigationItem中设置的做按钮、右按钮、标题等,会随着控制器的显示,也显示到navigationBar上

UINavigationItem属于MVC中的M,封装了要显示在UiNavigationBar上的数据

title: 标题
titleView :标题视图
leftBarButtonItem :左按钮
rightBarButtonItem :右按钮

6.UIBarButtonItem
-initWithBarButtonSystemItem:target:action:设置按钮样式及触发事件
-initWithTiltle:style:target:action: 设置标题的触发事件
-initWithImage:style:target:action:设置视图的触发事件
tintColor 设置tintColor可以影响添加在导航条上的系统样式的按钮的颜色
//设置一个自定义按钮
UIButton *wlButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
wlButton.backgroundColor = [UIColor yellowColor];
UIBarButtonItem *wlBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:wlButton];
self.navigationItem.rightBarButtonItem = wlBarButtonItem; (self 是一个在navigationController栈中的一个UIViewController)

7.导航栏上面提示信息
UIViewController.navigationItem.prompt = @"哈哈哈";
在几秒后消失可以加一个定时器 使 UIViewController.navigationItem.prompt = nil

8.//关闭半透明效果, 让所有的subviews起点坐标从导航栏的下方开始计算
self.navigationController.navigationBar.translucent = NO;

10.自定义navigationItem.leftBarButtonItem 时候,下面这个值为YSE则不覆盖返回按钮,默认是NO;
self.navigationItem.leftItemsSupplementBackButton = YES;

11.navigationController 和  UIScrollView 一起使用的时候一定要注意:

(1)新建一个工程,在Main.storyboard 拖一个UINavigationController设置为inital View Controller(打钩),

并把rootViewController换成一个UIViewController;

把拖进来的UIViewController Class换成ViewController

注意下面

ViewController中有一个Adjist  Scroll View Insets 默认是勾上的。

在ViewController 中创建一个scrollView,和一个topView,并把topView添加到scrollView上

- (void)viewDidLoad {
[super viewDidLoad]; UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
scrollView.backgroundColor = [UIColor redColor];
UIView *topView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
topView.backgroundColor = [UIColor yellowColor]; [scrollView addSubview:topView];
[self.view addSubview:scrollView];
}

运行效果:可以看到topView(黄色)往下偏移了64(状态栏:20+导航栏:44)的高度

把Adjist  Scroll View Insets勾去掉效果如下

这是因为UIViewController有下面这个属性:

@property(nonatomic,assign) BOOL automaticallyAdjustsScrollViewInsets NS_AVAILABLE_IOS(7_0); // Defaults to YES

代码中把这个属性置NO也可以消除对ScrollerView的影响;

12.往navigationBar 上添加图片时图片颜色显示不正确

- (void)creatNaviButton
{
UIImage *image = [UIImage imageNamed:@"ic_webview_back_normal.png"];
//保持图片颜色
UIBarButtonItem *leftButton = [[UIBarButtonItem alloc] initWithImage:[image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStylePlain target:self action:@selector(backAction)];
self.navigationItem.leftBarButtonItem = leftButton; }

下面是改变所有的barbutton的颜色

[self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];

UINavigationController使用的注意事项的更多相关文章

  1. jQuery UI resizable使用注意事项、实时等比例拉伸及你不知道的技巧

    这篇文章总结的是我在使用resizable插件的过程中,遇到的问题及变通应用的奇思妙想. 一.resizable使用注意事项 以下是我在jsfiddle上写的测试demo:http://jsfiddl ...

  2. Windows Server 2012 NIC Teaming介绍及注意事项

    Windows Server 2012 NIC Teaming介绍及注意事项 转载自:http://www.it165.net/os/html/201303/4799.html Windows Ser ...

  3. TODO:Golang指针使用注意事项

    TODO:Golang指针使用注意事项 先来看简单的例子1: 输出: 1 1 例子2: 输出: 1 3 例子1是使用值传递,Add方法不会做任何改变:例子2是使用指针传递,会改变地址,从而改变地址. ...

  4. app开发外包注意事项,2017最新资讯

    我们见过很多创业者,栽在这app外包上.很多创业者对于app外包这件事情不是特别重视,以为将事情交给app外包公司就完事了,实际上不是的.无论是从选择app外包公司还是签订合同.售后维护等各方面都有许 ...

  5. favicon.ioc使用以及注意事项

    1.效果 2.使用引入方法 2.1 注意事项:(把图标命名为favicon.ico,并且放在根目录下,同时使用Link标签,多重保险) 浏览器默认使用根目录下的favicon.ico 图标(如果你并没 ...

  6. ORACLE分区表梳理系列(二)- 分区表日常维护及注意事项(红字需要留意)

    版权声明:本文发布于http://www.cnblogs.com/yumiko/,版权由Yumiko_sunny所有,欢迎转载.转载时,请在文章明显位置注明原文链接.若在未经作者同意的情况下,将本文内 ...

  7. 【原】Masonry+UIScrollView的使用注意事项

    [原]Masonry+UIScrollView的使用注意事项 本文转载请注明出处 —— polobymulberry-博客园 1.问题描述 我想实现的使用在一个UIScrollView依次添加三个UI ...

  8. iOS UINavigationController(内容根据iOS编程编写)

    我们知道 UITabBarController 对象,可以通过使用该对象,用户可以切换不同的屏幕.当要切换的各个屏幕之间没有相互依存关系的时候,该对象可以很好的完成任务.但是当多个屏幕互有关系的时候, ...

  9. 《连载 | 物联网框架ServerSuperIO教程》- 5.轮询通讯模式开发及注意事项。附:网友制作的类库说明(CHM)

    1.C#跨平台物联网通讯框架ServerSuperIO(SSIO)介绍 <连载 | 物联网框架ServerSuperIO教程>1.4种通讯模式机制. <连载 | 物联网框架Serve ...

随机推荐

  1. webform处理过程

    一.post/get传值注意几点 post提交的时候,只有写了name属性且没有写disable=true表单元素(input,select,textarea)才会被提交. 如果不确定是get还是po ...

  2. Java的基础概念

    JDK (Java Development Kit) Java Developer Kit contains tools needed to develop the Java programs, an ...

  3. 第六篇、git常用的命令

    1.oscine git服务器地址 https://git.oschina.net/ 2.帐号:18775134221@163.com 密码:562011 3.创建私有的仓库 4.使用命令 4.1 配 ...

  4. Objective-C 学习笔记(Day 1)

    -------------------------------------------- Hello World //引入头文件 //c中的引入头文件的方式 //#include <stdio. ...

  5. Android_时间服务

    接着上一节,这次我查看了Android的时间服务,觉得帮助很大,解决了我很多疑问,下面我就自己总结了一下,加深了自己的印象,好记性不如烂笔头,还真讲得很不错,收下吧?看下图如何利用线程更新UI组件 重 ...

  6. validate中remote的用法

    jquery中的插件validate主要可以用于表单验证,极大地方便了我们,而validate中的remote方法更是非常的方便.以下介绍它的两个主要用途 1.注册时用于验证用户名是否存在 >& ...

  7. python(一)入门

    1.软件环境安装和配置 首先下载属于你的操作系统的对应的python安装包 2.傻瓜化下一步下一步 我直接勾选了配置python到path变量 然后完成 3.cmd命令行中测试一把 表示环境配置成功 ...

  8. mirantis fuel 学习

    这些天看了mirantis中puppet的使用,对puppet的认识有了更深入的理解.mirantis公司的fuel主要是为了方便部署生产环境的openstack的工具.主要是在集群中自动化的安装op ...

  9. Linux下为PHP安装oci8及pdo_oci扩展

    下载instantclient 以及sdk instantclient-basic-linux-x86-64-11.2.0.2.0.zip oracle-instantclient11.2-sdk-1 ...

  10. hdu 4550 卡片游戏 贪心

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4550 题意:有n(n <= 100)个0~9之间的卡片,从左往右将卡片放到之前的卡片最左边或者最 ...