I have a UIImageView and a UILabel, and want the content of the UILabel to mask the UIImageView. The goal is that the text is visible with content of image but everything else transparent.
Is there a simple way to mask a view by the contents of another view?
You can use QuartzCore Framework.
(Link project with QuartzCore.framework and import <QuartzCore/QuartzCore.h>).
@import QuartzCore;
Background of label must be clear color. Example:
self.imageView.layer.mask = self.label.layer;
self.imageView.layer.masksToBounds = YES;
In Interface Builder:

On device:

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With