5

I want to use webp image in UIImageView my ios project which is in Swift Language.

I tried using Matt Thompson library but it's not working with Swift project. I have imported the framework and did all required tasks but so many link errors.

How can I use webp Image in UIImageView in swift code?

Qiu
  • 5,651
  • 10
  • 49
  • 56
david35
  • 73
  • 1
  • 1
  • 7

2 Answers2

5

2019 SWIFT 5

I use SDWebImageWebPCoder and it works like magic.

Here is how to use it: -

  let webPCoder = SDImageWebPCoder.shared
    SDImageCodersManager.shared.addCoder(webPCoder)
    guard let webpURL = URL(string: webpUrlString)  else {return}
    DispatchQueue.main.async {
        imageView.sd_setImage(with: webpURL)
    }
Mussa Charles
  • 4,014
  • 2
  • 29
  • 24
3

You can use the Pod https://github.com/rs/SDWebImage

There is it really easy to load WebP Images from the Web

With Swift:

SDWebImageManager.shared().loadImage(with: url, options: .highPriority, progress: nil, completed: {(resultSet) in
            YOURWEBVIEW.image = resultSet.0

        })
Auryn
  • 1,117
  • 1
  • 13
  • 37