代码改变世界

tabBar选项卡的背景色如何修改

2011-11-03 22:52  张智清  阅读(2515)  评论(0编辑  收藏  举报

在tabBar区域加个视图

 1 CGRect frame = CGRectMake(0032048);
2
3 UIView *v = [[UIView alloc]initWithFrame:frame];
4
5 [v setBackgroundColor:[[UIColor allor]initWithRed:70.0/255.0
6
7 green:65.0/255.0
8
9 blue:62.0/255.0
10
11 alpha:1.0]];
12
13 [rootController.tabBar insertSubview:v atIndex:0];
14
15 [v release];

注意:

addSubview是将view添加到所有层的最顶层,相当于将insertSubView的atIndex参数设置成[view.subviews count]。这是因为子视图是以栈的方式存放的,每次添加子视图都是在最后面追加。insertSubview是添加到指定的层位置

[view addSubview:one view] 等价于[view insertSubview:oneview atIndex:[view.subviews count]];