views:

205

answers:

2

Hi

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:-

- (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.

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:-

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:-

-(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:-

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

A: 

Does anyone have anything for me?

Cheryl
A: 

been looking for several weeks for this also ... no luck here.

Jerry Walton