【IOS 开发学习总结-OC-54】★★ios开发UI 控件——UINavigationBar 与UINavigationController

本文是iOS开发的学习总结,重点探讨UINavigationBar和UINavigationController的使用。介绍了UINavigationBar的属性和方法,UINavigationItem的详细信息,以及UINavigationController如何管理UIViewController。还讲解了在UINavigationController底部添加工具条的方法,并提供了示例代码。
摘要由CSDN通过智能技术生成

【IOS 开发学习总结-OC-54】★★ios开发UI 控件——UINavigationBar 与UINavigationController

UINavigationController是个控制器,用户交互行为主要靠UINavigationBar来完成。

UINavigationBar

UINavigationBar——通常位于屏幕顶端,继承了 UIView 控件,通常只是作为多个UINavigationItem 的容器。它通过 stack (栈)的形式管理多个UINavigationItem,所以每次UINavigationBar上只能看到一个UINavigationItem对象。 它们二者的关系如下图:
这里写图片描述

UINavigationBar中的属性和方法有:

NS_CLASS_AVAILABLE_IOS(2_0) @interface UINavigationBar : UIView <NSCoding, UIBarPositioning> 

@property(nonatomic,assign) UIBarStyle barStyle;
@property(nullable,nonatomic,weak) id<UINavigationBarDelegate> delegate;

@property(nonatomic,assign,getter=isTranslucent) BOOL translucent NS_AVAILABLE_IOS(3_0) UI_APPEARANCE_SELECTOR; // Default is NO on iOS 6 and earlier. Always YES if barStyle is set to UIBarStyleBlackTranslucent(黑色透明)

// Pushing a navigation item displays the item's title in the center of the navigation bar.
// The previous top navigation item (if it exists) is displayed as a "back" button on the left.
- (void)pushNavigationItem:(UINavigationItem *)item animated:(BOOL)animated;
//将一个pushNavigationItem压入UINavigationBar 的栈中。

- (nullable UINavigationItem *)popNavigationItemAnimated:(BOOL)animated; 
//将UINavigationBar栈顶的UINavigationItem弹出
// Returns the item that was popped.

@property(nullable, nonatomic,readonly,strong) UINavigationItem *topItem;
//返回最顶层的UINavigationItem控件

@property(nullable, nonatomic,readonly,strong) UINavigationItem *backItem;
//返回UINavigationItem控件最顶层下面的UINavigationItem控件

@property(nullable,nonatomic,copy) NSArray<UINavigationItem *> *items;
//返回UINavigationBar包含的多个UINavigationItem控件

- (void)setItems:(nullable NSArray<UINavigationItem *> *)items animated:(BOOL)animated; 
// 同时为UINavigationBar设置多个UINavigationItem控件
// If animated is YES, then simulate a push or pop depending on whether the new top item was previously in the stack.

@property(null_resettable, nonatomic,strong) UIColor *tintColor;//着色

@property(nullable, nonatomic,strong) UIColor *barTintColor NS_AVAILABLE_IOS(7_0) UI_APPEARANCE_SELECTOR;  //导航栏着色  default is nil

- (void)setBackgroundImage:(nullable UIImage *)backgroundImage forBarPosition:(UIBarPosition)barPosition barMetrics:(UIBarMetrics)barMetrics NS_AVAILABLE_IOS(7_0) UI_APPEARANCE_SELECTOR;
//通过导航栏位置和量度设置背景图片 官方注解:Sets the background image to use for a given bar position and set of metrics(指标,度量).

- (nullable UIImage *)backgroundImageForBarPosition:(UIBarPosition)barPosition barMetrics:(UIBarMetrics)barMetrics NS_AVAILABLE_IOS(7_0) UI_APPEARANCE_SELECTOR;
//通过导航栏位置和量度获取背景图片

- (void)setBackgroundImage:(nullable UIImage *)backgroundImage forBarMetrics:(UIBarMetrics)barMetrics NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;
//通过导航栏量度设置背景图片

- (nullable UIImage *)backgroundImageForBarMetrics:(UIBarMetrics)barMetrics NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;
//通过导航栏量度获取背景图片

@property(nullable, nonatomic,strong) UIImage *shadowImage NS_AVAILABLE_IOS(6_0) UI_APPEARANCE_SELECTOR;//阴影图片

@property(nullable,
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值