UINavigationController、UINavigationBa的详解和导航控制栏的定制

本文详细介绍了UINavigationController的概念和作用,它作为构建分层应用的主要工具,管理多个内容视图的切换。主要内容包括导航栏、内容视图和工具栏的基本样式,以及如何使用代码进行导航控制和定制。还探讨了UINavigationController的代理方法、常用方法和属性,以及UINavigationBar的定制,如自定义标题视图和背景。最后,展示了如何设置导航栏的背景图片和条目。
摘要由CSDN通过智能技术生成

第一.UINavigationController的基本概念

UINavigationController是用于构建分层应用程序的主要工具,管理者多个内容视图的换入和换出,自身提供了切换的动画效果.

第二.基本样式

主要三部分:

1.导航栏:NavigationBar,在最上面,主要负责视图的弹出和控制主视图,高度是44px/32px(横过来),上面的logo是20*20px

2.内容视图,中间部分,用于显示内容

3.工具栏(UIToolBar),默认是隐藏的,用户可以自己添加工具栏,高度是44px/32px(横过来)

第三、示例代码:

 RootViewController *rootViewController=[[[RootViewController alloc] init] autorelease];
    NSLog(@"the first controller is %@",rootViewController.navigationController);
    UINavigationController *controller=[[[UINavigationController alloc] initWithRootViewController:rootViewController] autorelease];
    NSLog(@"the end controller is %@",rootViewController.navigationController);


输出结果是:

2013-09-10 19:21:13.236 simpleNavigation[1841:c07] the first controller is (null)

2013-09-10 19:21:13.239 simpleNavigation[1841:c07] the end controller is <UINavigationController: 0x892eb70>

分析:
在执行,下面语句之前
 UINavigationController *controller=[[[UINavigationController alloc] initWithRootViewController:rootViewController] autorelease];


rootViewController的navigatoncontroller为空,在执行了该语句之后navigationcontroller就有值了

    [self.navigationControllerpushViewController:secondVCanimated:YES];就可以实现跳转了

        [self.navigationControllersetToolbarHidden:NOanimated:YES];  //设置Toolbar是否显示

         [self.navigationControllersetNavigationBarHidden:NO]; //设置导航栏是否显示

第三UINavagitionController的代理,通过设置代理监听视图控制器的切换

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值