Kingfisher
Kingfisher copied to clipboard
How to set GIF image using Data Type?
Hi. I would like to create a GIF image using a data type. However, using a kingfisher seems to be able to create images only with URLs. Is there a way?
You could use an ImageDataProvider. More specifically, a RawImageDataProvider should be fine.
Please give me some examples..
I just needed answers for this case too so i am posting this if someone needs an example in the future :) :
if let bundleURL = Bundle.main.url(forResource: "the-name-of-your-gif", withExtension: "gif"), let data = try? Data(contentsOf: bundleURL) {
let provider = RawImageDataProvider(data: data, cacheKey: "key-for-your-cache")
imageView.kf.setImage(with: provider)
}
And your GIF file should be outside your Assets if you use the above code.