Declan McKenna
Declan McKenna

Reputation: 4870

Why has my image lost its transparency?

I'm creating a xib file in which there is a black marbled background displayed using a UIImageView and several UIButtons placed over it with images within them. The images are transparent with the exception of a dotted white line skirting their perimeter. I am using pngs for my images and I have tried setting them as both the image and background image. How can I restore the alpha channel within these images and place them within a UIButton?

How the image should look with transparency against a black marbled background.

How the image should look against a marbled black background

How the image looks at present.

enter image description here

Upvotes: 0

Views: 172

Answers (2)

Abhishek
Abhishek

Reputation: 2253

Try to add quartzCore framework in your framework folder, then import the header:

#import < QuartzCore/QuartzCore.h >

and set the image maskToBounds yes and set in corner if you want.

[yuorImageView.layer setMaskToBounds:YES];

Upvotes: 0

skram
skram

Reputation: 5314

You may need to set the UIButton type to UIButtonTypeCustom and not Rounded Rect

enter image description here

Upvotes: 3

Related Questions