Reputation: 93
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?
Upvotes: 7
Views: 18649
Reputation: 4442
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)
}
Upvotes: 5
Reputation: 1176
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
})
Upvotes: 5