How to use WebP image in UIImageView Swift
Asked Answered
G

2

7

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?

Guilbert answered 19/8, 2015 at 9:32 Comment(0)
E
5

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

        })
Enjambement answered 12/6, 2017 at 12:47 Comment(0)
I
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)
    }
Impressible answered 5/8, 2019 at 2:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.