简体   繁体   English

iPhone SDK-UITabBarConroller和自定义设计

[英]iPhone SDK - UITabBarConroller and custom design

I am having a problem with my tab bars at the bottom of the screen. 我在屏幕底部的选项卡栏有问题。 The designer has decided it should be one colour (not black) when inactive and another colour when active. 设计人员已决定在不使用时应为一种颜色(不是黑色),而在使用时应为另一种颜色。 I have worked out how to replace the main colour of the tabbar by subclassing UITabBarController and doing this:- 我已经解决了如何通过子类化UITabBarController并执行以下操作来替换选项卡的主要颜色的方法:

- (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];    

} }

I just can't see how to make the active tabbar be a separate colour when it is selected. 我只是看不到如何在选择时将活动标签栏变为单独的颜色。 I have tried subclassing UITabBarItem but there doesn't seem to be any property for me to set to change the background colour of the tab. 我尝试子类化UITabBarItem,但似乎没有任何属性可以设置以更改选项卡的背景色。

They also want to have the icons on the tab bar not be blue and grey and I can't figure out how to do that. 他们还希望选项卡栏上的图标不是蓝色和灰色,我不知道该怎么做。 In the ViewController for one tab bar item I have put this into viewdidload:- 在ViewController的一个选项卡栏项目中,我已将其放入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;

and in my subclass of UITabBarItem I have put this:- 在我的UITabBarItem子类中,我输入了以下内容:

-(UIImage *) selectedImage{
     return self.customHighlightedImage;
 }

Only I don't see the icon at all. 只有我完全看不到该图标。

If I put this into the viewDidLoad of my subclass of UITabBarController:- 如果我将其放入UITabBarController的子类的viewDidLoad中:

for (UITabBarItem *item in tabBar1.items){
    item.image = [UIImage imageNamed:@"starcopy.png"]; 
}

Then all my tab bars have the icon but they are blue (and grey when inactive) how would I get them not to become blue but stay their original colour? 然后,我所有的标签栏都带有图标,但是它们是蓝色的(不活动时为灰色),我如何让它们不变成蓝色,而是保持其原始颜色?

If you have any light on this problem please help as I have been banking my head on the wall for 2 days now and it's getting me down. 如果您对此问题有任何了解,请提供帮助,因为我已经将脑袋贴在墙上两天了,这让我很沮丧。 Thanks in advance Cheryl 预先感谢谢丽尔

It seems to be impossible to be done without using private API calls. 不使用私有API调用似乎不可能完成。 The only solution I can see right now is to create a complete custom TabBar. 我现在看到的唯一解决方案是创建一个完整的自定义TabBar。 That however is a lot of work just to get an icon presented in a different color. 但是,要使图标以不同的颜色显示,需要进行大量工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM