[英]Add UILabel Mask to UIVisualEffectView
I have an UIImageView
, UIVisualEffectView
, and an UILabel
on my ViewController
. 我的
ViewController
上有一个UIImageView
, UIVisualEffectView
和一个UILabel
。 The UIVisualEffectView
blurs the UIImageView
behind it. UIVisualEffectView
使后面的UIImageView
模糊。 I would like to mask the UIVisualEffectView
with the text of the UILabel
. 我想用
UILabel
的文本掩盖UIVisualEffectView
。 Like this image: 喜欢这张图片:
How would I do this? 我该怎么做? I'm using Swift.
我正在使用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
您需要将
UILabel
分配为UIVisualEfectView的UIVisualEfectView
,技巧是需要为UIVisualEfectView
和UILabel
添加一个容器,并将该容器视图的背景色设置为UIColor.clear
self.visualEfectView.mask = self.label
self.visualEfectView.layer.masksToBounds = true
View Hierarchy Setup 查看层次结构设置
Result 结果
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.