Легко сделать фоновый вырез с нормальной меткой, используя, например, следующий код:
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
Вотжелаемый эффект