我想在单元格中使用 JSQMessageView 在 UIImage 上加载 gif 图像。我无法访问任何 UIImageView 所以我这样做是为了改变媒体视图。但是,图像没有动画。有可能做我想做的事吗?
这是我的代码:
let urlString = Helpers.getUrlFromGiphyText(text: message.body!)
if let url = URL(string: urlString) {
KingfisherManager.shared.retrieveImage(with: url, options:
[.processor(DefaultImageProcessor.default),
.cacheSerializer(FormatIndicatedCacheSerializer.gif)],
progressBlock:
{ receivedSize, totalSize in
print("(indexPath.row + 1): (receivedSize)/(totalSize)")
}, completionHandler: { image, error, cacheType, imageURL in
if let gifImage = image {
let mediaItem = JSQPhotoMediaItem(image: gifImage)
cell.mediaView = mediaItem?.mediaView()
}
})
}