Masking UIView/UIImageView to cutout transparent text
问题 How can I mask an UIView or UIImageView so that a text is cutout from it? I googled a lot and it seems that many people struggled the same. Most irritating I always tried to invert the alpha of a snapshotted view to get the result. What I want looks like this: 回答1: This is the custom mask label. import UIKit final class MaskLabel: UILabel { // MARK: - IBInspectoable @IBInspectable var cornerRadius: CGFloat { get { return self.layer.cornerRadius } set { self.layer.cornerRadius = newValue } }