1

I would like to know in UITabBar,if there's any way to set the colored(original) images to tab bar items,Upon several searches I came to find out the way to change the color of tab bar i.e. set a colored bar image which will do the trick.

[self.homeTabbar.tabBar insertSubview:[[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tab.JPG"]] autorelease] atIndex:0]; 

I have read the responses in several posts that apple would love to use only that black colored tab bar and grey images with blue color as selected for tab bar items.

After changing the color of tab bar it looks as shown in screen shot below:

enter image description here

Now as u can see the add and all titled item images are not the way they are assigned,i.e. the actual images are color as shown below:

enter image description here

enter image description here

Wondering why the original image gets affected when using tab bar items.

Can any one please provide a sample solution/suggestion rather than suggesting to go for a twitter app or some other suggestions already given to posts of this kind which would be tough for a beginner like me.

Thanks all in advance :)

Eshwar Chaitanya
  • 697
  • 10
  • 21

3 Answers3

2

You can only do this in iOS 5 or above:

Look at this method on UITabBarItem:

- (void)setFinishedSelectedImage:(UIImage *)selectedImage withFinishedUnselectedImage:(UIImage *)unselectedImage
Amy Worrall
  • 16,250
  • 3
  • 42
  • 65
  • Oh,but my version of ios is 4.3.,I will let u know about it when testing in ios5.Thanks for the response – Eshwar Chaitanya Feb 27 '12 at 15:15
  • Can u post some sample code under that method plz,just for making an idea – Eshwar Chaitanya Feb 27 '12 at 15:16
  • I don't have any sample code I'm afraid. Just call that method on the tab bar item that you want to have a different image, and give it two images, one for when the tab is selected (active) and one for when it is not. – Amy Worrall Feb 27 '12 at 15:24
  • If you really want to use custom images on a version of iOS before 5, you could try [PESTabBarAddition](http://snyderp.tumblr.com/post/79975799/pestabbaraddition-is-a-pair-of-classes-i-wrote-to). Do bear in mind that Apple don't support this on anything before iOS 5. – Amy Worrall Feb 27 '12 at 15:25
  • Thanks Mr.Amorya for all the concern and the useful information,I will consider all these and build my code accordingly,thanks once again,TC :) – Eshwar Chaitanya Feb 28 '12 at 05:27
1
[myTabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"aboutus.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"undo.png"]]

You can use this. But it work only for iOS 5 and above versions. I am also getting same problem I solve by checking device version for iOS 5. Still finding solution for iOS 4 and below.

Josh Darnell
  • 11,304
  • 9
  • 38
  • 66
python
  • 1,407
  • 1
  • 15
  • 31
  • Thank u so much,but I got similar answer above, nevertheless a very useful answer :) – Eshwar Chaitanya May 02 '12 at 06:18
  • I solve this issue for ios4 by checking ios version. And used border image for ios4. Then without custom tabbar u will get decent tababar with tabbar items for ios4 and original images effect for ios5. May be u like this idea. – python May 02 '12 at 14:48
  • Hmm,sounds good buddy,will try to implement and get back to you – Eshwar Chaitanya May 03 '12 at 04:38
0

[_manageCardController.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"managecards_icon.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"managecards_icon.png"]];

Kemo
  • 488
  • 6
  • 12