Proudly animate Gif on iOS with less than 100 lines of code.
Basically this is a copycat of SwiftGif. Differences:
- Play gif as it is.
- UIImageView load gif from URL.
Since this is just an Extension, you can just
- download the GifExt.swift file
- add it to your project.
- use it like as below
// create animated UIImage
let localGifURL = Bundle.main.url(forResource: "laugh", withExtension: "gif")
let gifFile = UIImage.gif(url:localGifURL!)
localImageView.image = gifFile
// load gif from web
let webGifURL = URL(string: "https://media.giphy.com/media/3og0IuvANdUUmpVeA8/giphy.gif")
webImageView.loadGif(url: webGifURL!)