1.UIBarButtonItem
可以设置其 图片 文字 以及样式
也可以自定义customView
@interface UIBarButtonItem : UIBarItem <NSCoding>
- (instancetype)initWithTitle:(nullable NSString *)title style:(UIBarButtonItemStyle)style target:(nullable id)target action:(nullable SEL)action;
- (instancetype)initWithImage:(nullable UIImage *)image style:(UIBarButtonItemStyle)style target:(nullable id)target action:(nullable SEL)action;
- (instancetype)initWithCustomView:(UIView *)customView;
2.UINavigationItem
一个navigationItem中有多个UIBarButtonItem
一个UIVIewController只有一个navigationItem
@interface UINavigationItem : NSObject <NSCoding>
@property(nullable, nonatomic,copy) NSString *title; // Title when topmost on the stack. default is nil
@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.
@property(nullable, nonatomic,strong) UIBarButtonItem *leftBarButtonItem;
@property(nullable, nonatomic,strong) UIBarButtonItem *rightBarButtonItem;
@property (nonatomic, retain, nullable) UISearchController *searchController API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(tvos);
3.UINavigationBar
navigationBar中包含很多navigationItem
要想改变和设置导航栏字体或者样式等应设置navigationBar对应属性
@interface UINavigationBar : UIView <NSCoding, UIBarPositioning>
- (void)pushNavigationItem:(UINavigationItem *)item animated:(BOOL)animated;
@property(nullable, nonatomic,readonly,strong) UINavigationItem *topItem;
@property(nullable, nonatomic,readonly,strong) UINavigationItem *backItem;
@property(null_resettable, nonatomic,strong) UIColor *tintColor;
@property(nullable, nonatomic,strong) UIColor *barTintColor;
@property(nullable, nonatomic,strong) UIImage *shadowImage NS_AVAILABLE_IOS(6_0) UI_APPEARANCE_SELECTOR;
4.UINavigationController
控制器栈里面有很多控制器:根控制器,二级控制器等
通过navigationBar管理操作切换这些控制器
@property(nonatomic,readonly) UINavigationBar *navigationBar; //每个NavigationController都有一个操作控制器栈的Bar
UIViewController获取对应的navigationBar以及navigationItem
- 当UIViewController被push到navigationController中,可以通过以下方法获取对应的NavigationController和navigationItem
- 每一个UIViewController 只有一个navigationItem
- 每一个NavigationController 只有一个navigationBar
- 每一个navigationBar 有很多个navigationItem
- 每一个navigationItem 有很多UIBarButtonItem 如:leftBarButtonItem、rightBarButtonItem、backBarButtonItem
@interface UIViewController (UINavigationControllerItem)
@property(nonatomic,readonly,strong) UINavigationItem *navigationItem; // Created on-demand so that a view controller may customize its navigation appearance.
@property(nonatomic) BOOL hidesBottomBarWhenPushed __TVOS_PROHIBITED; // If YES, then when this view controller is pushed into a controller hierarchy with a bottom bar (like a tab bar), the bottom bar will slide out. Default is NO.
@property(nullable, nonatomic,readonly,strong) UINavigationController *navigationController; // If this view controller has been pushed onto a navigation controller, return it.
@end
网友评论