Reputation: 1752
I have an attributedString with 100 NSTextAttachments(contains image of 400kb). When i scroll the textview, it is lagging, When i did the same in textkit 1, it is butter smooth. It can be because of how textkit 1 & 2 layout the elements.
let attachment = NSTextAttachment()
attachment.image = UIImage(named: "image2")
let attachmentString = NSAttributedString(attachment: attachment)
let mutableAttributedString = NSMutableAttributedString(attributedString: textView.attributedText)
for _ in 0...100 {
mutableAttributedString.append(NSAttributedString(string: "\n"))
mutableAttributedString.append(attachmentString)
}
textView.attributedText = mutableAttributedString
How to handle images in textkit 2 so that it feels smooth while scrolling textview?
Upvotes: 0
Views: 17