Want to highlight a helpful answer? Upvote!

Did someone help you, or did an answer or User Tip resolve your issue? Upvote by selecting the upvote arrow. Your feedback helps others! Learn more about when to upvote >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

UITabBarItem image ¿bug?

Hi!
I'm having troubles showing an image on a tab bar item. Tried these two ways:

1.- From IB, select the tab bar item and on the attributes inspector, select from the image drop down menu the one to be displayed.

2.- Programatically:
NSString* path=((NSBundle mainBundle) pathForResource:@"myImage" ofType:@"png");
theTabBarItem.image =((UIImage alloc) initWithContentsOfFile:path);

With both methods got the same issue: instead of the image I just get a blue square, both on the device and simulator (iphone).

Any help will be welcome, I'm quite new to this environment so, I don't really know whether it's my fault or I'm dealing with a bug.

Thx a lot!

iMac, Mac OS X (10.5.4)

Posted on Jul 15, 2008 4:33 AM

Reply
3 replies

Jul 15, 2008 5:32 AM in response to Pabl0

The documentation says +"The alpha values in the source image are used to create the unselected and selected images—opaque values are ignored."+

In other words, the actual colours of your image are ignored. The only interesting thing about each pixel, as far as UITabBarItem is concerned, is whether it's transparent or not.

The behaviour you are seeing is what will happen if you are using an image that is full of opaque pixels - in other words, what a normal, rational human being would think of as "an image".

How you make pixels transparent depends on the image editing program you are using.

UITabBarItem image ¿bug?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.