UINavigationController的使用

1.书本上将的UINavigationController的创建都是通过IB创建的.直接拖一个到windows.xib上,然后在delegate上设置outlet.

2.代码上的展示就要更直接些了.

//1.初始化:

//使用时需要一个图控制器来做为UINavigationController根视视图控制器,本例中为TestViewController:

UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:[[TestViewController alloc] init]];

[window addSubview:nav.view];

 

 

#define COOKBOOK_PURPLE_COLOR [UIColor colorWithRed:0.20392f green:0.19607f blue:0.61176f alpha:1.0f]

#define BARBUTTON(TITLE, SELECTOR) [[[UIBarButtonItem alloc] initWithTitle:TITLE style:UIBarButtonItemStylePlain target:self action:SELECTOR] autorelease]

//若一个视图控制器在栈中,则可以调用navigationControllernavigationItem来获得导航控制器或项目





//2.TestViewControllerviewDidLoad函数中,可以对导航条属性进行设置:

self.navigationController.navigationBar.tintColor  COOKBOOK_PURPLE_COLOR;

 

 

self.navigationItem.rightBarButtonItem  BARBUTTON(@"Flip", @selector(flip:));

 

// Set up the segmented control for picking the animation direction

UISegmentedControl *seg = [[[UISegmentedControl alloc] initWithItems:[@"Left Right" componentsSeparatedByString:@" "]] autorelease];

seg.selectedSegmentIndex = 0;

seg.segmentedControlStyle = UISegmentedControlStyleBar;

self.navigationItem.titleView = seg;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值