我在屏幕底部的标签栏出现问题。设计师已经决定,它在不活动时应该是一种颜色(不是黑色),而在活动时应该是另一种颜色。我已经摸索出了如何通过继承的UITabBarController和这样做是为了取代的TabBar的主色: -iPhone SDK - UITabBarConroller和自定义设计
- (void)viewDidLoad {
[super viewDidLoad];
CGRect frame = CGRectMake(0.0, 0, self.view.bounds.size.width, self.view.bounds.size.height);
UIView *v = [[UIView alloc] initWithFrame:frame];
//get percentage values from digitalcolour meter and enter as decimals
v.backgroundColor = [UIColor colorWithRed:.0 green:.706 blue:.863 alpha:1];
[tabBar1 insertSubview:v atIndex:0];
[v release];
}
我只是不明白如何使活跃的TabBar是一个单独的颜色,当它被选中。我已经试过UITabBarItem的子类,但似乎没有任何属性让我设置更改选项卡的背景颜色。
他们也希望有标签栏上的图标不是蓝色和灰色,我无法弄清楚如何做到这一点。在视图控制器的一个标签栏项目我已经把这变成viewDidLoad中: -
myTabBarItem *tabItem = [[myTabBarItem alloc] initWithTitle:@"listOOO" image:[UIImage imageNamed:@"starcopy.png"] tag:1];
tabItem.customHighlightedImage=[UIImage imageNamed:@"starcopy.png"];
self.tabBarItem=tabItem;
[tabItem release];
tabItem=nil;
在我UITabBarItem的子类,我已经把这个: -
-(UIImage *) selectedImage{
return self.customHighlightedImage;
}
只是我没有看到这个图标在所有。
如果我把这个到viewDidLoad中我的UITabBarController的子类: -
for (UITabBarItem *item in tabBar1.items){
item.image = [UIImage imageNamed:@"starcopy.png"];
}
然后我所有的标签栏有图标,但它们是蓝色(灰色未激活时),我将如何让他们不变成蓝色但保持原有颜色?
如果您对这个问题的任何光请帮助,因为我一直在银行我的头在墙上2天现在和它让我下来。 在此先感谢 谢丽尔