Reputation: 126507
How do I insert an NSTextAttachment
at a specific location in an NSAttributedString
?
Upvotes: 0
Views: 441
Reputation: 126507
let attributedString = NSAttributedString(attachment: textAttachment)
let mutableAttributedText = NSMutableAttributedString(attributedString: textView.attributedText)
mutableAttributedText.replaceCharacters(in: selectedRange, with: attributedString)
textView.attributedText = mutableAttributedText
Upvotes: 0