我在文本字段的附件视图中添加了按钮。 点击此按钮,我想在文本字段的文本中显示图像/图标。
我该怎么做?
我试过了:
let fullString = NSMutableAttributedString(string: self.text ?? "")
let image1Attachment = NSTextAttachment( image1Attachment.image = UIImage(named: "dummyUser")
let image1String = NSAttributedString(attachment: image1Attachment)
fullString.append(image1String)
self.attributedText = fullString