UIImage masked with Label
suggest changeThis masks the image to the shape of the label’s letters. Only the non-transparent parts of the mask show the image, so the label needs a clear background and an opaque text color. The Objective-C code uses the label’s layer as the mask, which removes that layer from the label:
Objective-C
self.maskImage.layer.mask = self.maskLabel.layer;
self.maskImage.layer.masksToBounds = YES;
Swift 3
maskImageView.mask = maskLabel
maskImageView.layer.masksToBounds = true
Here is the result:
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents