Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 UIImageView 和一个 UILabel,并希望 UILabel 的内容来掩盖 UIImageView。目标是文本与图像内容一起可见,但其他所有内容都是透明的。
有没有一种简单的方法可以用另一个视图的内容来掩盖一个视图?
您可以使用QuartzCore Framework.
QuartzCore Framework
(链接项目QuartzCore.framework并导入 <QuartzCore/QuartzCore.h>)。
QuartzCore.framework
@import QuartzCore;
标签的背景必须是清晰的颜色。例子:
self.imageView.layer.mask = self.label.layer; self.imageView.layer.masksToBounds = YES;
在界面生成器中:
在设备上: