In my app I need to use .gif
and I did searched on it. Everyone asked to use UIImage.gifImageWithName("funny")
or UIImage.gifWithName("jeremy")
for adding .gif
file. But I'm getting error on those Type 'UIImage' has no member 'gifWithName'
. How to solve those Issues and How to use .gif
in my app.
Just find a GIF that you want and press the “copy link” button. Then, paste the link where you want to use your GIF. On most sites, the GIF will work automatically. Use Gboard: The Google Keyboard for Android, iPhone, and iPad has a built-in GIF function that allows you to use GIFs anywhere, even in text messages.
Download UIImage+Gif.swift file from https://github.com/bahlo/SwiftGif/tree/master/SwiftGifCommon and put into your project..
// An animated UIImage
let Gif = UIImage.gif(name: "jerry")
// A UIImageView with async loading
let imageView = UIImageView()
imageView.loadGif(name: "tom")]
iOS won't support .gif
images directly. You have to use latest version of third party library like SDWebImage. The simplified solution is to use Webview.
Or else, You can use UIImageView+Extension
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With