2

I updated Kingfisher from 4.10 to 5.7,however,the gif didn't show on imageView with the same code.

Here is my code:

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

It's work well with Kingfiser 4.10.

无夜之星辰
  • 5,426
  • 4
  • 25
  • 48

1 Answers1

4

Kingfisher library has local image provider that must be used to load local image.

So your code should be changed to this:

let path = Bundle.main.url(forResource: "loading", withExtension: "gif")!
let resource = LocalFileImageDataProvider(fileURL: path)
imageView.kf.setImage(with: resource)
Najdan Tomić
  • 2,071
  • 16
  • 25
  • hi, i want to load network gif image, how can i do? Thanks – famfamfam May 12 '21 at 12:23
  • 2
    @famfamfam since this is question for Kingfisher library I guess you would like to load remote GIF using Kingfisher. You can do it like this: `imageView.kf.setImage(with: URL(string: "https://cdn.journaldev.com/wp-content/uploads/2017/04/android-collapsing-toolbar-default-output.gif"))`. – Najdan Tomić May 16 '21 at 08:17