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

UI 常用方法总结之--- UINavigationController (不断更新中)

时间:2014-10-13 12:03:29      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:des   style   color   io   使用   ar   for   strong   sp   

UINavigationController : UIViewController


1.创建UINavigationController对象

UINavigationController *navCV = [[UINavigationController alloc]initWithRootViewController:mainVC]; 

通常和

self.window.rootViewController = navCV;

连用


2.- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated; 

推出第二个页面

eg:[self.navigationController pushViewController:secondVC animated:YES];


3.- (UIViewController *)popViewControllerAnimated:(BOOL)animated; 

返回上一视图

eg:[self.navigationController popViewControllerAnimated:YES];


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

返回指定视图

eg:获得viewController的栈

    UIViewController *viewC = [self.navigationController.viewControllers objectAtIndex:0];

    [self.navigationController popToViewController:viewC animated:YES];


5.- (NSArray *)popToRootViewControllerAnimated:(BOOL)animated; 

返回根视图

eg:[self.navigationController popToRootViewControllerAnimated:YES];




UINavigationItem : NSObject <NSCoding>

每个页面要显示在导航栏上的内容(标题,两边按钮信息)


1.rightBarButtonItem

创建导航栏右边按钮

参数1 选择一个系统提供的图标信息

eg:self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(button:)]autorelease];


2.leftBarButtonItem

创建导航栏左边按钮

eg:self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"iconfont-yinle.png"] style:UIBarButtonItemStylePlain target:self action:@selector(button:)]autorelease];


3.hidesBackButton

隐藏返回按钮

eg:self.navigationItem.hidesBackButton = YES;


4.titleView

标题相关设置

eg:self.navigationItem.titleView = [[[UISegmentedControl alloc]initWithItems:@[@"111",@"222"]]autorelease];



UINavigationbar


1.translucent

是否透明

eg:self.navigationController.navigationBar.translucent = YES;


2.barTintColor

bar的颜色eg:self.navigationController.navigationBar.barTintColor = [UIColor grayColor];


3.setNavigationBarHidden

隐藏bar

e.g.:[self.navigationController setNavigationBarHidden:NO];


4.automaticallyAdjustsScrollViewInsets

取消掉scrollView的系统设置的UIEdgeInsets

e.g.:elf.automaticallyAdjustsScrollViewInsets = YES;

(当页面出现不可预知问题时可以尝试使用这个开关)


5.setBackgroundImage

设置bar背景图片

eg[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"2.png"] forBarMetrics:UIBarMetricsDefault];

UI 常用方法总结之--- UINavigationController (不断更新中)

标签:des   style   color   io   使用   ar   for   strong   sp   

原文地址:http://blog.csdn.net/qq11231325/article/details/40039259

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