swiftuitableviewanimated-gifnstextattachment

swift tablecell NSTextAttachment + GIF -> gif image not animate


im try to add gif image to table cell + text attribute, i worked on nstextattachment to show gif image normally, the gif image showed but it does not animate. did someone explain me the problem?

let attachment = NSTextAttachment()
attachment.image = UIImage.gif(name: data.Data)
attachment.bounds = CGRect(x: 0, y: (font.capHeight - gifSize).rounded() / 2, width: gifSize, height: gifSize)
let replacement = NSAttributedString(attachment: attachment)
attributedString.replaceCharacters(in: aMatch.range, with: replacement)

enter image description here


Solution

  • Gif image will not work with NSTextAttachment. You can use UIImageView for .gif images.