Skip to content

Commit

Permalink
优化(html转富文本时,图片所在位置的属性忘记设置了)
Browse files Browse the repository at this point in the history
  • Loading branch information
rztime committed Oct 8, 2024
1 parent 64f8587 commit 15b1850
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions RZRichTextView/Classes/LabelRZRich.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public extension UILabel {
}
let temp = NSMutableAttributedString(attributedString: attr)
let attach = NSMutableAttributedString(attachment: attachment)
attach.addAttributes(temp.attributes(at: range.location, effectiveRange: nil), range: .init(location: 0, length: attach.length))
if needPreView {
attach.addAttributes([.rztapLabel: "\(attachment)"], range: .init(location: 0, length: 1))
}
Expand Down
4 changes: 3 additions & 1 deletion RZRichTextView/Classes/RZHtml.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ public extension RZRichTextView {
}
let atts = self.textStorage.rt.attachments()
if let a = atts.first(where: {$0.0 == attachment}) {
self.textStorage.replaceCharacters(in: a.1, with: .init(attachment: a.0))
let attr = NSMutableAttributedString.init(attachment: a.0)
attr.addAttributes(self.textStorage.attributes(at: a.1.location, effectiveRange: nil), range: .init(location: 0, length: attr.length))
self.textStorage.replaceCharacters(in: a.1, with: attr)
self.fixAttachmentInfo()
}
}
Expand Down

0 comments on commit 15b1850

Please sign in to comment.