Dejell
Dejell

Reputation: 14317

Set alpha on one color in UIImage

I have this PNG image: (the area in the grey borders is transparent)

enter image description here

I would like only the grey corners to have alpha of 0.5

If I set

[imgView setAlpha:0.5f];

Also the transparent area in the middle retrieves a semi-white color.

How can I do it?

Upvotes: 0

Views: 184

Answers (2)

Obj-Swift
Obj-Swift

Reputation: 2942

You should add one imageview below your desired image. and adjust alpha of that image.

Upvotes: 0

Nikolai Ruhe
Nikolai Ruhe

Reputation: 81848

Any reason why you don't just change the original image file? If that's not possible, you could put a white (black?) rectangle with 50% opacity below the image.

Of course there are many ways to do this but you would need to tell us more about your use case.

Upvotes: 3

Related Questions