首页 > 解决方案 > 当我更新翠鸟时,本地 gif 没有显示

问题描述

我将 Kingfisher 从 4.10 更新到 5.7,但是,gif 没有使用相同的代码显示在 imageView 上。

这是我的代码:

let path = Bundle.main.path(forResource: "loading", ofType: "gif")!
let resource = ImageResource(downloadURL: URL(fileURLWithPath: path))
imageView.kf.setImage(with: resource)

它适用于 Kingfiser 4.10。

标签: iosswiftkingfisher

解决方案


Kingfisher 库具有本地图像提供程序,必须用于加载本地图像。

所以你的代码应该改成这样:

let path = Bundle.main.url(forResource: "loading", withExtension: "gif")!
let resource = LocalFileImageDataProvider(fileURL: path)
imageView.kf.setImage(with: resource)

推荐阅读