Fade out UIView?

I have an UIView here that I'd like to partially fade the bottom of. Basically I want the alpha value to decrease the further down on the UIView we go. So the top of the UIView is completely visible, while the bottom part has an alpha value of 0.

Anybody got any suggestion as to how to accomplish this?

Upvotes: 2

Views: 1016

Answers (1)

Lily Ballard
Lily Ballard

Reputation: 185671

CALayer has a property called mask, which is designed for doing precisely this sort of effect. If you assign another CALayer to the mask (one that has no superlayer), the alpha channel of that second CALayer is used when compositing the first CALayer.

Be careful, though, as using the mask property has a significant performance hit.

Upvotes: 2

Related Questions