UINavigationController 导航控制器

初始方法:

- (id)initWithRootViewControl:(UIViewController *)rootViewController

//初始化时,传递一个视图控制器的参数,作为导航控制器的根视图控制器,导航控制器实例加载完成后,根视图控制器的视图会被添加到导航控制器中

入栈操作:

//从导航控制器某一个视图里面把另一个视图Push进导航控制器栈中。

[self.navigationController pushViewController:(UIViewController *)viewController animated:(BOOL)]

出栈:

//退出当前视图,回到上一视图

[self.navigationController popViewControllerAnimated:YES]

//从某个视图跳转到根视图控制器

[self.navigationController popToRootViewControllerAnimated:(BOOL)animated;

//从导航控制器获取到它所有的视图:

@property(nonatomic,copy)NSArray *viewController;

//导航执行器跳转到指定的视图控制器(必须是在栈里的)

- (NSArray *)popToViewController:(UIViewController *)viewController animated:(BOOL)animated;

UINavigationBar

自带的导航条

属性:

1、@property(nonatomic,assign) UIBarStyle 导航条样式

2、@property(nonatomic) BOOL clipsToBounds 设置导航栏超出部分是否自动裁剪

3、@property(nonatomic,getter=isNavigationBarHidden)BOOL navigationBarHidden //隐藏导航条的属性

方法:

1、

//iOS 5.0以后版本,用来设置导航条的背景图和显示模式(如果图片大,不会压缩)

- (void)setBackgroundImage:(UIImage *)backgroundImage forBarMetrics:(UIBarMetrics)barMetrics

2、

//隐藏导航条

- (void)setNavigationBarHidden:(BOOL)hidden animated:(BOOL)animated;

UINavigationItem

导航栏内容

属性:

1、title //设置标题,显示在导航栏中间

2、titleView //设置标题视图,显示在导航栏的中间位置

3、leftBarButtonItem //左侧按钮

4、rightBarButtonItem //右侧按钮

方法:

1、//设置左侧按钮

- (void)setLeftBarButtonItem:(UIBarButtonItem *)item animated:(BOOL)animated;

2、//设置右侧按钮

- (void)setRightBarButtonItem:(UIBarButtonItem *)item animated:(BOOL)animated;

3、//设置左侧的一组按钮

- (void)setLeftBarButtonItems:(NSArray *)items animated:(BOOL)animated;

4、//设置右侧的一组按钮

- (void)setRightBarButtonItems:(NSArray *)items animated:(BOOL)animated;

UIBarButtonItem初始化方法:

1、

- (id)initWithImage:(UIImage *)image style:(UIBarButtonItemStyle)style target:(id)target action:(SEL)action

2、

- (id)initWithTitle:(NSString *)title style:(UIBarButtonItemStyle)style target:(id)target action:(SEL)action

3、

- (id)initWithBarButtonSystemItem:(UIBarButtonSystemItem)systemItem target:(id)target action:(SEL)action

4、

-(id)initWithCustomView:(UIView *)customView;

UIToolBar

1、//设置隐藏显示属性

toolbarHidden

2、//设置隐藏方法

- (void)setToolbarHidden:(BOOL)hidden animated:(BOOL)animated

3、//设置UIToolBar

- (void)setBackgroundImage:(UIImage *)backgroundImage forToolbarPosition:(UIToolbarPosition)topOrBottom barMetrics:(UIBarMetrics)barMetrics;

原文地址:https://www.cnblogs.com/durwards/p/4555623.html