我有一个如下所示的属性字符串要显示在标签中。
let someText = NSMutableAttributedString(string: "This is a sample text with")
let imageAttachment = NSTextAttachment()
imageAttachment.image = UIImage(named: "icon")
let imageString = NSAttributedString(attachment: imageAttachment)
someText.append(imageString)
someText.append(NSAttributedString(string: "attached")
somelabel.attributedText = someText
Run Code Online (Sandbox Code Playgroud)
标签显示This is a sample text with 'image' attached
如何识别点击图像(而不是文本)来执行操作?