码迷,mamicode.com
首页 > 其他好文 > 详细

UINavigationItem 是 UINavigationBar 上的东西

时间:2016-03-24 10:13:50      阅读:190      评论:0      收藏:0      [点我收藏+]

标签:

导航栏是通过push与pop的堆栈操作来对item进行管理的,同样,每一个Item自身也有许多属性可供我们进行自定制。

Item,从英文上来理解,它可以解释为一个项目,因此,item不是一个简单的label标题,也不是一个简单的button按钮,它是导航栏中管理的一个项目的抽象。说起来有些难于理解,通过代码,我们就能很好的理解Item的意义。

 

 

以下是一些方法和属性

 1 //NS_CLASS_AVAILABLE_IOS(2_0) @interface UINavigationItem : NSObject <NSCoding>
 2 //
 3 //初始化一个带有文本的UINavigationItem
 4   - (instancetype)initWithTitle:(NSString *)title NS_DESIGNATED_INITIALIZER;
 5   - (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
 6 //
 7 //设置和获取UINavigationItem的文本
 8   @property(nullable, nonatomic,copy)   NSString        *title;             // Title when topmost on the stack. default is nil
 9 //设置一个View类型的item:
10   @property(nullable, nonatomic,strong) UIView          *titleView;         // Custom view to use in lieu of a title. May be sized horizontally. Only used when item is topmost on the stack.
11 
12 //这段文字会显示在item的上方:
13   @property(nullable,nonatomic,copy)   NSString *prompt __TVOS_PROHIBITED;     // Explanatory text to display above the navigation bar buttons.
14 
15 //一个UINavigationItem中,还可以包含许多BarButtonItem,BarButtonItem是一系列的按钮,会出现在导航栏的左侧或者右侧
16 //设置返回按钮
17   @property(nullable,nonatomic,strong) UIBarButtonItem *backBarButtonItem __TVOS_PROHIBITED; // Bar button item to use for the back button in the child navigation item.
18 //
19 //设置在push出来新的item的时候,隐藏前面的返回按钮
20   @property(nonatomic,assign) BOOL hidesBackButton __TVOS_PROHIBITED; // If YES, this navigation item will hide the back button when it‘s on top of the stack.
21   - (void)setHidesBackButton:(BOOL)hidesBackButton animated:(BOOL)animated __TVOS_PROHIBITED;
22 //
23 ///* Use these properties to set multiple items in a navigation bar.
24 // The older single properties (leftBarButtonItem and rightBarButtonItem) now refer to
25 // the first item in the respective array of items.
26 //
27 // NOTE: You‘ll achieve the best results if you use either the singular properties or
28 // the plural properties consistently and don‘t try to mix them.
29 //
30 // leftBarButtonItems are placed in the navigation bar left to right with the first
31 // item in the list at the left outside edge and left aligned.
32 // rightBarButtonItems are placed right to left with the first item in the list at
33 // the right outside edge and right aligned.
34 // */
35 //设置左右按钮组
36   @property(nullable,nonatomic,copy) NSArray<UIBarButtonItem *> *leftBarButtonItems NS_AVAILABLE_IOS(5_0);
37   @property(nullable,nonatomic,copy) NSArray<UIBarButtonItem *> *rightBarButtonItems NS_AVAILABLE_IOS(5_0);
38   - (void)setLeftBarButtonItems:(nullable NSArray<UIBarButtonItem *> *)items animated:(BOOL)animated NS_AVAILABLE_IOS(5_0);
39   - (void)setRightBarButtonItems:(nullable NSArray<UIBarButtonItem *> *)items animated:(BOOL)animated NS_AVAILABLE_IOS(5_0);
40 //
41 ///* By default, the leftItemsSupplementBackButton property is NO. In this case,
42 // the back button is not drawn and the left item or items replace it. If you
43 // would like the left items to appear in addition to the back button (as opposed to instead of it)
44 // set leftItemsSupplementBackButton to YES.
45 // */
46 //是否隐藏返回按钮,
47   @property(nonatomic) BOOL leftItemsSupplementBackButton NS_AVAILABLE_IOS(5_0) __TVOS_PROHIBITED;
48 //
49 //// Some navigation items want to display a custom left or right item when they‘re on top of the stack.
50 //// A custom left item replaces the regular back button unless you set leftItemsSupplementBackButton to YES
51 //设置左右按钮
52   @property(nullable, nonatomic,strong) UIBarButtonItem *leftBarButtonItem;
53   @property(nullable, nonatomic,strong) UIBarButtonItem *rightBarButtonItem;
54   - (void)setLeftBarButtonItem:(nullable UIBarButtonItem *)item animated:(BOOL)animated;
55   - (void)setRightBarButtonItem:(nullable UIBarButtonItem *)item animated:(BOOL)animated;
56 //
57   @end

 

UINavigationItem 是 UINavigationBar 上的东西

标签:

原文地址:http://www.cnblogs.com/kinghx/p/5314063.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!