美文网首页iOS UIKit框架学习
iOS UIKit框架学习—UINavigationBar

iOS UIKit框架学习—UINavigationBar

作者: Wynter_Wang | 来源:发表于2017-01-25 11:38 被阅读70次

    一种支持分层内容导航的视觉控制,最常用于导航控制器

    @class UINavigationItem, UIBarButtonItem, UIImage, UIColor;
    @protocol UINavigationBarDelegate;
    
    NS_CLASS_AVAILABLE_IOS(2_0) @interface UINavigationBar : UIView <NSCoding, UIBarPositioning>
    // 外观样式
    @property(nonatomic,assign) UIBarStyle barStyle UI_APPEARANCE_SELECTOR __TVOS_PROHIBITED;
    // 代理
    @property(nullable,nonatomic,weak) id<UINavigationBarDelegate> delegate;
    // 是否半透明显示
    @property(nonatomic,assign,getter=isTranslucent) BOOL translucent NS_AVAILABLE_IOS(3_0) UI_APPEARANCE_SELECTOR;
    
    // 将给定导航项推到导航的栏栈上,并更新界面
    - (void)pushNavigationItem:(UINavigationItem *)item animated:(BOOL)animated;
    // 返回被弹出的项目
    - (nullable UINavigationItem *)popNavigationItemAnimated:(BOOL)animated; 
    // 导航栏顶部的导航项
    @property(nullable, nonatomic,readonly,strong) UINavigationItem *topItem;
    // 导航栏堆栈中最顶层以下的项目
    @property(nullable, nonatomic,readonly,strong) UINavigationItem *backItem;
    // 导航栏管理的导航项数组
    @property(nullable,nonatomic,copy) NSArray<UINavigationItem *> *items;
    // 替换当前导航栏上的项目
    - (void)setItems:(nullable NSArray<UINavigationItem *> *)items animated:(BOOL)animated;
    // 底色
    @property(null_resettable, nonatomic,strong) UIColor *tintColor;
    @property(nullable, nonatomic,strong) UIColor *barTintColor NS_AVAILABLE_IOS(7_0) UI_APPEARANCE_SELECTOR;
    // 设置用于在给定位置和给定度量的背景的图像
    - (void)setBackgroundImage:(nullable UIImage *)backgroundImage forBarPosition:(UIBarPosition)barPosition barMetrics:(UIBarMetrics)barMetrics NS_AVAILABLE_IOS(7_0) UI_APPEARANCE_SELECTOR;
    // 返回用于在给定位置和给定度量的背景的图像
    - (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,nonatomic,copy) NSDictionary<NSString *,id> *titleTextAttributes NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;
    // 设置标题垂直位置调整
    - (void)setTitleVerticalPositionAdjustment:(CGFloat)adjustment forBarMetrics:(UIBarMetrics)barMetrics NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;
    // 返回标题垂直调整的数值
    - (CGFloat)titleVerticalPositionAdjustmentForBarMetrics:(UIBarMetrics)barMetrics NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;
    // 返回按钮的图片
    @property(nullable,nonatomic,strong) UIImage *backIndicatorImage NS_AVAILABLE_IOS(7_0) UI_APPEARANCE_SELECTOR __TVOS_PROHIBITED;
    // push和pop操作用于遮挡的图片
    @property(nullable,nonatomic,strong) UIImage *backIndicatorTransitionMaskImage NS_AVAILABLE_IOS(7_0) UI_APPEARANCE_SELECTOR __TVOS_PROHIBITED;
    
    @end
    
    @protocol UINavigationBarDelegate <UIBarPositioningDelegate>
    
    @optional
    // 导航栏是否应该推送选项
    - (BOOL)navigationBar:(UINavigationBar *)navigationBar shouldPushItem:(UINavigationItem *)item;
    // 将项目推到导航栏上
    - (void)navigationBar:(UINavigationBar *)navigationBar didPushItem:(UINavigationItem *)item;
    // 导航栏是否应该弹出选项
    - (BOOL)navigationBar:(UINavigationBar *)navigationBar shouldPopItem:(UINavigationItem *)item;
    // 从导航栏中弹出
    - (void)navigationBar:(UINavigationBar *)navigationBar didPopItem:(UINavigationItem *)item;
    
    @end
    
    NS_CLASS_AVAILABLE_IOS(2_0) @interface UINavigationItem : NSObject <NSCoding>
    // 初始化并设置标题
    - (instancetype)initWithTitle:(NSString *)title NS_DESIGNATED_INITIALIZER;
    - (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
    // 标题
    @property(nullable, nonatomic,copy)   NSString        *title;
    // 自定义标题视图
    @property(nullable, nonatomic,strong) UIView          *titleView;
    // 显示在导航栏顶部不得单行文本
    @property(nullable,nonatomic,copy)   NSString *prompt __TVOS_PROHIBITED;
    // 返回按钮项
    @property(nullable,nonatomic,strong) UIBarButtonItem *backBarButtonItem __TVOS_PROHIBITED;
    // 是否隐藏返回按钮
    @property(nonatomic,assign) BOOL hidesBackButton __TVOS_PROHIBITED;
    // 隐藏返回按钮并带动画效果
    - (void)setHidesBackButton:(BOOL)hidesBackButton animated:(BOOL)animated __TVOS_PROHIBITED;
    // 导航栏左侧操作按钮数组
    @property(nullable,nonatomic,copy) NSArray<UIBarButtonItem *> *leftBarButtonItems NS_AVAILABLE_IOS(5_0);
    // 导航栏右侧操作按钮数组
    @property(nullable,nonatomic,copy) NSArray<UIBarButtonItem *> *rightBarButtonItems NS_AVAILABLE_IOS(5_0);
    - (void)setLeftBarButtonItems:(nullable NSArray<UIBarButtonItem *> *)items animated:(BOOL)animated NS_AVAILABLE_IOS(5_0);
    - (void)setRightBarButtonItems:(nullable NSArray<UIBarButtonItem *> *)items animated:(BOOL)animated NS_AVAILABLE_IOS(5_0);
    // 除了返回按钮外是否显示左侧的项目
    @property(nonatomic) BOOL leftItemsSupplementBackButton NS_AVAILABLE_IOS(5_0) __TVOS_PROHIBITED;
    
    // 左侧按钮视图
    @property(nullable, nonatomic,strong) UIBarButtonItem *leftBarButtonItem;
    // 右侧按钮视图
    @property(nullable, nonatomic,strong) UIBarButtonItem *rightBarButtonItem;
    - (void)setLeftBarButtonItem:(nullable UIBarButtonItem *)item animated:(BOOL)animated;
    - (void)setRightBarButtonItem:(nullable UIBarButtonItem *)item animated:(BOOL)animated;
    
    @end
    
    

    相关文章

      网友评论

        本文标题:iOS UIKit框架学习—UINavigationBar

        本文链接:https://www.haomeiwen.com/subject/humtittx.html