小编Rio*_*Rio的帖子

识别标签中显示的属性字符串中的图像点击

我有一个如下所示的属性字符串要显示在标签中。

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

如何识别点击图像(而不是文本)来执行操作?

xcode uilabel ios nsmutableattributedstring swift

5
推荐指数
1
解决办法
1504
查看次数

标签 统计

ios ×1

nsmutableattributedstring ×1

swift ×1

uilabel ×1

xcode ×1