参考文章:http://blog.csdn.net/totogo2010/article/details/7681879,参考了这篇文章,写的超级好,自己他的基础上加上了自己的理解。

下面的图显示了导航控制器的流程。最左侧是根视图,当用户点击其中的General项时,General视图会滑入屏幕;当用户继续点击Auto-Lock项时,Auto-Lock视图将滑入屏幕。相应地,在对象管理上,导航控制器使用了导航堆栈。根视图控制器在堆栈最底层,接下来入栈的是General视图控制器和Auto-Lock视图控制器。可以调用pushViewControllerAnimated:方法将视图控制器推入栈顶,也可以调用popViewControllerAnimated:方法将视图控制器弹出堆栈。

UINavigationController有Navigation bar  ,Navigation View ,Navigation toobar等组成。

UINavigationController界面解析图片:

uinavigationController、uinavigationBar、uinavigationBarItem区分:

uinavigationController是个容器,里面可以装很多uiviewController。装这么多uiviewController让用户怎么控制它们呢,总得有个工具吧。这个工具就是uinavigationBar。一个容器就这么一个bar,相当于控制台吧。但是,管理那么多uiviewController,控制台上得按钮啊、标题啊,都千篇一律是不是看起来太无聊了。为了解决这个问题,uinavigationController为每个uiviewController生成一个uinavigationBarItem,通过这个uinavigationBarItem可以改变控制台“上面”得按钮和标题。

代码来实现导航视图界面的链接:

[self.navController pushViewController:rootView animated:YES]<pre name="code" class="objc">// 下面的代码是实现了一个全新的界面的创建。
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[testScrollViewViewControllerViewController alloc] initWithNibName:@"testScrollViewViewControllerViewController" bundle:nil];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];


代码来实现导航视图界面的标题:

revigationBar.title = @”sakfjlsjf”;
//添加标题
[revigationBar setTitle:@ ”sakfjlsjf”];
//另一种方法

代码来实现导航视图界面的UIBarButtonItem:

UIBarButtonItem *leftButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(AddMethod)];
self.navigationItem.leftBarButtonItem = leftButton;
//添加NavigationBar左右控件,初始化方法是定义一个按钮,然后将按钮和方法链接起来。

下图为UIBarButtonItem:系统自带的按钮风格:

用代码实现BarButton中间添加一个view:

NSArray *array = [NSArray arrayWithObjects:@"鸡翅",@"排骨", nil];
UISegmentedControl *segmentedController = [[UISegmentedControl alloc] initWithItems:array];
[segmentedController addTarget:self action:nil forControlEvents:UIControlEventValueChanged];
self.navigationItem.titleView = segmentedController;
UIButton *BarTitle = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[BarTitle setTitle:@"登陆界面" forState:UIControlStateNormal];
[BarTitle sizeToFit];
self.navigationItem.titleView = BarTitle;

代码实现自定义backBarButtonItem

UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithTitle:@"返回登陆" style:UIBarButtonItemStyleDone target:self action:nil];
self.navigationItem.backBarButtonItem = button;
//我们先创建一个UIBarButtonItem类,然后使用将他赋值给backBarButtonItem这个实例。

代码实现在ToolBar上添加UIBarButtonItem:

UIBarButtonItem *first = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:self action:nil];
UIBarButtonItem *second = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:nil];
UIBarButtonItem *three = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:nil];
UIBarButtonItem *four = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:nil];
UIBarButtonItem *flexItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
NSArray *toolBar = [NSArray arrayWithObjects:flexItem, first, flexItem, second, flexItem, three, flexItem, four, flexItem, nil];
self.toolbarItems = toolBar;

用代码实现自定义 navigationbar 的左右按钮

 //    自定义按钮
UIButton *actionBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[actionBtn setTitle:@"" forState:UIControlStateNormal]; UIImage *imgDefault = [UIImage imageNamed:@"Arrow"];
[actionBtn setFrame:CGRectMake(0, 0, imgDefault.size.width, imgDefault.size.height)];
[actionBtn setBackgroundImage:imgDefault forState:UIControlStateNormal];
[actionBtn addTarget:self action:@selector(backButtonAction) forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:actionBtn];

用代码实现自定义navigationbar的title标题

 自定义标题
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0 , 100, 44)];
titleLabel.backgroundColor = [UIColor clearColor];
titleLabel.font = [UIFont systemFontOfSize:17];
titleLabel.textColor = [UIColor colorWithRed:0 green:0.44 blue:0.70 alpha:1 ];//设置文本颜色
titleLabel.textAlignment = UITextAlignmentCenter;
titleLabel.text = @"Resert Password";
self.navigationItem.titleView = titleLabel;

用代码实现改变navigationbar的颜色

self.navigationController.navigationBar.tintColor = [UIColor whiteColor];

在navigation的编写的过程中,如果我们将navigation的navigationBar设置为透明,那么视图在xib中的位置不会改变;反之,视图中的xib中的位置将会整体下移64个单位。下面是改透明度的代码

//    在这里将导航栏设置为透明
self.navigationController.navigationBar.translucent = YES;

iOS NavigaitonController详解(code版)的更多相关文章

  1. 【转】IOS AutoLayout详解(三)用代码实现(附Demo下载)

    转载自:blog.csdn.net/hello_hwc IOS SDK详解 前言: 在开发的过程中,有时候创建View没办法通过Storyboard来进行,又需要AutoLayout,这时候用代码创建 ...

  2. 《FPGA设计技巧与案例开发详解-第二版》全套资料包

    本人参与写的一本书(TimeQuest一章由我所写),希望大家多多支持: 全书配套资料上传各大网盘资料中附送大量源码,你值得拥有--<FPGA设计技巧与案例开发详解-第二版>全套资料包-V ...

  3. IOS SDK详解

    来源:http://blog.csdn.net/column/details/huangwenchen-ios-sdk.html?page=1#42803301 博客专栏>移动开发专栏>I ...

  4. iOS路由详解

    本文如题,路由详解,注定是一篇详细解释iOS路由原理及使用的文章,由于此时正在外地出差,无法详细一一写出,只能不定时的补充. 一.什么是iOS路由 路由一词来源于路由器,可以实现层级之间消息转发的功能 ...

  5. IOS 手势详解

    在IOS中手势可以让用户有很好的体验,因此我们有必要去了解一下手势. (在设置手势是有很多值得注意的地方) *是需要设置为Yes的点击无法响应* *要把手势添加到所需点击的View,否则无法响应* 手 ...

  6. IOS SizeClasses 详解

    SizeClasses 详解 iOS 8在应用界面的可视化设计上添加了一个新的特性-Size Classes.对于任何设备来说,界面的宽度和高度都只分为三种描述:紧凑,任意和宽松.这样开发者便可以无视 ...

  7. iOS模式详解—「runtime面试、工作」看我就 🐒 了 ^_^.

    Write in the first[写在最前] 对于从事 iOS 开发人员来说,当提到 ** runtime时,我想都可以说出来 「runtime 运行时」和基本使用的方法.相信很多开发者跟我当初一 ...

  8. iOS 模式详解—「runtime面试、工作」看我就 🐒 了 ^_^.

    引导 Copyright © PBwaterln Unauthorized shall not be *copy reprinted* . 对于从事 iOS 开发人员来说,所有的人都会答出「runti ...

  9. ios学习--详解IPhone动画效果类型及实现方法

    详解IPhone动画效果类型及实现方法是本文要介绍的内容,主要介绍了iphone中动画的实现方法,不多说,我们一起来看内容. 实现iphone漂亮的动画效果主要有两种方法,一种是UIView层面的,一 ...

随机推荐

  1. prepare—Article【准备篇】之SSH_tool#PuTTY

    第一:下载PuTTY: url :     http://www.openssh.com/ 下载界面: 安装后: 详解以上命令 ① ② PuTTYgen is a key generator. It ...

  2. 结合rpyc使用python实现动态升级的方法

    动态升级,就是程序不退出的情况下,将其代码更新的策略.假设集群含有多个机器,然后每个机器部署一套程序,当升级的时候就要去所有的上面部署一把. (1)有个包装程序专门负责接口并检查是否需要更新,当需要更 ...

  3. 自定义UICollectionViewController之后 如何设置UICollectionView的布局方式--备用

    我们很多时候使用UICollectionView 可能都是直接创建 UICollectionView   通过初始化的时候  传入一个布局对象的方式来使用UICollectionView 比如我们之前 ...

  4. 跨平台的WatiForSingleObject实现

    移植win32程序时,有一个难点就是涉及到内核对象的操作,需要模拟win32的实现. 其中比较奇葩的一个是WaitForSingleObject系列. Linux中没有类似的timeout实现,模拟这 ...

  5. Zoj 3868 GCD Expectation

    给一个集合,大小为n , 求所有子集的gcd 的期望和 . 期望的定义为 这个子集的最大公约数的K次方 : 每个元素被选中的概率是等可能的 即概率 p = (发生的事件数)/(总的事件数); 总的事件 ...

  6. bzoj 3669: [Noi2014]魔法森林 动态树

    3669: [Noi2014]魔法森林 Time Limit: 30 Sec  Memory Limit: 512 MBSubmit: 363  Solved: 202[Submit][Status] ...

  7. [BZOJ 1559] [JSOI2009] 密码 【AC自动机DP】

    题目链接:BZOJ - 1559 题目分析 将给定的串建成AC自动机,然后在AC自动机上状压DP. 转移边就是Father -> Son 或 Now -> Fail. f[i][j][k] ...

  8. windows驱动开发推荐书籍

    [作者] 猪头三 个人网站 :http://www.x86asm.com/ [序言] 很多人都对驱动开发有兴趣,但往往找不到正确的学习方式.当然这跟驱动开发的本土化资料少有关系.大多学的驱动开发资料都 ...

  9. Buddy system伙伴分配器实现

    wikipedia:http://en.wikipedia.org/wiki/Buddy_memory_allocation The buddy memory allocation technique ...

  10. android 常见分辨率(mdpi、hdpi 、xhdpi、xxhdpi )及屏幕适配注意事

    1.1 手机常见分辨率: 4:3VGA     640*480 (Video Graphics Array)QVGA  320*240 (Quarter VGA)HVGA  480*320 (Half ...