Wednesday, January 28, 2015

CALayer alpha

I come across this problem today where I am supposed to change the opacity of an image (It is actually an UIImage)

The problem is that there is no alpha or opacity property for UIImage, if I want to mess with the opacity of the image, I would have to add it to a UIImageView and change the opacity level of the UIImageView.

And then I realized that, the image is sitting on top of a CALayer, and after checking the documentation, I noticed that CALayer has an opacity property (Note: NOT alpha).

So to change the opacity of my CALayer,
layer.opacity = (float);

No comments:

Post a Comment