navigationController 内部有一个栈的实现,管理所有的view , 栈的底部是 根视图, 栈的顶部是当前显示的视图。
A navigation controller object manages the currently displayed screens using the navigation stack. At the bottom of this stack is the root view controller and at the top of the stack is the view controller currently being displayed.
如果要显示新的视图:[self.navigationController pushViewController:viewController animated:YES];
所有继承自 UIViewController 的类,都有 navigationController 和 navigationItem 的属性,如果该类被加入到一个navigationController 的栈中,它的属性就指向 这个navigationController 。
navigationBar 一般有 左右两个按钮:
左侧按钮是 回退 或 取消:
The bar button item on the left side of the navigation bar allows for navigation back to the previous view controller on the navigation stack. The navigation controller updates the left side of the navigation bar as follows:
-
If the new top-level view controller has a custom left bar button item, that item is displayed. To specify a custom left bar button item, set the leftBarButtonItem
property of the view controller’s navigation item.
-
If the top-level view controller does not have a custom left bar button item, but the navigation item of the previous view controller has a valid item in its backBarButtonItem
property, the navigation bar displays that item.
-
If a custom bar button item is not specified by either of the view controllers, a default back button is used and its title is set to the value of the
title
property of the previous view controller—that is, the view controller one level down on the stack. (If there is only one view controller on the navigation stack, no back button is displayed.)
如果没有手动设置,那么显示默认的回退按钮,title 就是上个视图的title , 指向上个视图,就是栈的下一级。
如果当前视图是 rootView ,可能需要设置 取消 按钮。
navigationBar 右侧按钮一般是手动定制的。
-
If the new top-level view controller has a custom right bar button item, that item is displayed. To specify a custom right bar button item, set the rightBarButtonItem
property of the view controller’s navigation item.
-
If no custom right bar button item is specified, the navigation bar displays nothing on the right side of the bar.
注意:
When this navigation item is immediately below the top item in the stack, the navigation controller derives the back button for the navigation bar from this navigation item. When this property is nil
, the navigation item uses the value in its title
property to create an appropriate back button. If you want to specify a custom image or title for the back button, you can assign a custom bar button item (with your custom title or image) to this property instead. When configuring your bar button item, do not assign a custom view to it; the navigation item ignores custom views in the back bar button anyway.
注意2:
定制 UIbuttion 可拉伸背景图片,ios 4.3 是 UIImage stretchableImageWithLeftCapWidth:topCapHeight,ios 5后是 UIImage resizableImageWithCapInsets
Return Value:A new image object with the specified cap insets.
他们返回的是一个新的 UIImage 对象,而不是改变现有的对象
分享到:
相关推荐
BSY项目UIBarButtonItem 向右或向左
没有默认边框样式的 UIBarButtonItem 的自定义图像或文本。 版本 1.1 概述 当您不希望 Apple 应用到它的默认边框样式时,使用它代替UIBarButtonItem 。 创建一个更干净的栏按钮项目,或者只是为创作自由留出更多...
iOS系统导航栏中有leftBarButtonItem和rightBarButtonItem,我们可以根据自己的需求来自定义这两个UIBarButtonItem。 本文主要介绍的是关于iOS改变UIBarButtonItem大小的相关内容,下面话不多说了,来一起看看详细的...
UIBarButtonItem rightBarButtonItem leftBarButtonItem IOS Demo 代码
来源:github/UIBarButtonItem-Licence:MIT作者:Valnet Inc. 在UIBarButtonItem上添加数字角标(Badge)。
解决iOS7 UIBarButtonItem右移错位问题
在项目开发过程中,遇到一种情况,需要自定义UIBarButtonItem,来实现分享样式,并在iPad中弹出系统分享框(UIActivityViewController),系统分享框需要指定显示位置(barButtonItem)。而自定义的UIBarButtonItem ...
主要介绍了iOS应用中自定义UIBarButtonItem导航按钮的创建方法,文中举了一个自定义图片的UIBarButtonItem实例,比较具有代表性,需要的朋友可以参考下
NirSideMenu 基于 通过左右两个UIBarButtonItem触发侧滑菜单,并对左侧菜单进行了基本定制
菜鸟一个,第一次发代码,把UIBarButtonItem的点击事件写成Block了,感觉用着挺方便了.请大家指教.
FTPopOverMenu, 简单易用的弹出Menu,支持UIButton,UIBarButtonItem,以及任何UIView或CGRect。Github demo地址:https://github.com/liufengting/FTPopOverMenu
ALAction块ALActionBlocks是UIControl,UIBarButtonItem和UIGestureRecognizer上的Objective-C类别,该类别允许处理带有块的控件事件。 用块处理控制事件删除控制事件的块给您提供了对块中控件的弱引用与UIControl,...
self.navigationController.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithTitle:@" :grinning_face_with_smiling_eyes: " NorImage:nil HigImage:nil Target:self Action:@selector(leftIt
主要介绍了iOS应用开发中导航栏按钮UIBarButtonItem的添加教程,文中详细介绍了使用UINavigationController导航控制器添加的过程,需要的朋友可以参考下
引用```UIBarButtonItem XYMenu.h```头文件 - (void)xy_showMenuWithImages:(NSArray *)imagesArr titles:(NSArray *)titles menuType:(XYMenuType)menuType currentNavVC:(UINavigationController *)...
[[UIBarButtonItem alloc] initWithTitle与[[UIBarButtonItem alloc] initWithBarButtonSystemItem的区别 - http://blog.csdn.net/moon_prince2013/article/details/49068643 Objective-C中的SEL - ...
它可以从任何UIView ,任何UIBarButtonItem和任何CGRect 。 最简单的API,使您可以在一行代码中更改样式。 有时我想为每个单元格客户,所以我将全局设置和单元格设置分开。 例如:我的项目经理希望显示某些菜单项,...
[[UIBarButtonItem alloc] initWithTitle与[[UIBarButtonItem alloc] initWithBarButtonSystemItem的区别 - http://blog.csdn.net/moon_prince2013/article/details/49068643 Objective-C中的SEL - ...