I have an UIImageView
, UIVisualEffectView
, and an UILabel
on my ViewController
. The UIVisualEffectView
blurs the UIImageView
behind it. I would like to mask the UIVisualEffectView
with the text of the UILabel
. Like this image:
How would I do this? I'm using Swift.
You need to assign your UILabel
as maskView of your UIVisualEfectView
and the trick is that you need add a container for your UIVisualEfectView
and your UILabel
and set the background color for this container view as UIColor.clear
self.visualEfectView.mask = self.label
self.visualEfectView.layer.masksToBounds = true
View Hierarchy Setup
Result