如何使用UITextView文本作为蒙版快速抠出背景?

时间:2018-06-25 22:52:06

标签: swift uitextview

例如,使用以下代码很容易使用常规标签进行背景剪裁:

    var coloredBackground : UIView!
    coloredBackground = UIView(frame: view.bounds)
    coloredBackground.backgroundColor = .blue
    coloredBackground.center = view.center
    view.addSubview(coloredBackground)

    let imageView = UIImageView(frame: coloredBackground.bounds)
    imageView.image = UIImage(named: "image")
    coloredBackground.addSubview(imageView)

    let label = UILabel(frame: coloredBackground.bounds)
    label.text = "stackoverflow"
    label.font = UIFont(name: "Helvetica", size: 30)
    coloredBackground.addSubview(label)

    imageView.mask = label

但是我似乎无法将其应用于UITextView

这是理想的效果 enter image description here

0 个答案:

没有答案