PDA

View Full Version : UIBarButtonItem Image not showing




darkpegasus
Jul 18, 2008, 10:51 AM
I have a UIBarButtonItem that I am trying to create with initWithImage. However, whenever I run the app I get a small button with a blank white box instead of the image. Am I missing something?

UIBarButtonItem *myToolbarItem = [[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"myImage.png"]
style:UIBarButtonItemStyleBordered
target:self
action:nil] autorelease];



grimjim
Jul 18, 2008, 02:11 PM
This snippet of the UIBarButtonItem documentation might have some bearing on it:
The alpha values in the source image are used to create the images—opaque values are ignored

So, if your image is rectangular and opaque, all you will see is the rectangle. Try using an image with an alpha channel, and you should get better results.