Reputation: 5813
I am trying to draw an image that has some transparent regions. I load the image using
image = [UIImage imageNamed:@"testimage.png"];
and draw it using
[image drawAtPoint:CGPointMake(0,0)];
The UIView on which I draw the image is not opaque (and it has a transparent background color).
The problem is that everything works fine on the simulator, but when I run the app on my iPhone the transparent color becomes black! Can anyone pinpoint my error?
Upvotes: 3
Views: 4177
Reputation: 449
The correct answer to this problem is the .PNG format you are saving your image with. If you save as PNG-8, you will run into this problem more often that not, since it only supports 1 transparent color. If you open your .PNG file and then re-save it as a 24-bit format, you will gain genuine transparency.
Reference this thread for discussion and clarification.
Upvotes: 2
Reputation: 5813
I solved my problem by loading it into colorsync and then saving it.
Upvotes: 0
Reputation: 748
I had the same problem today with a picture of mine. I've created the picture my self in GraphicConverter.
My solution was to add an alpha channel to the picture. I did this with GraphicConverter using the command found in Picture => Alpha Channel => Create Alpha Channel with transparency . It could be that the command has a different name for you as I use the app with a german language setting.
Hope this helps.
Upvotes: 3