In my rich text project I use NSTextAttachment to add an image, set attachment.bounds, and it works. Convert NSAttributedString to NSData and store it in sqlite3 and then take it out. Attachment.bounds is lost.How to solve this problem? Thanks a lot.
Code Block let attachment = NSTextAttachment() attachment.image = image let textPaddingTop:CGFloat = (richTextView.font!.lineHeight - richTextView.font!.pointSize) / 2 attachment.bounds = CGRect.init(x: 0, y: -textPaddingTop, width: image.size.width, height: image.size.height)