user1406716 user1406716 - 6 months ago 56
iOS Question

Unable to show a *.gif file in a UIImageView in swift

I have a *.gif file that I want to show in a

. I have tried the library FLAnimatedImage, code below. Result is just a static image.

class LoginVC: UIViewController, UITextFieldDelegate {

@IBOutlet weak var img_popup: FLAnimatedImageView!

var img_popupraw: FLAnimatedImage = FLAnimatedImage(animatedGIFData: NSData(contentsOfFile: "ShitTalk_LoadingAnimation.gif"))

override func viewDidLoad() {
img_popup.animatedImage = img_popupraw



Open to any alternative ways to show animating gif directly from a gif file. I am using Swift.


I strongly recommend you to use SwiftGif.

Import the Gif.swift in your project and do the following:

// Returns an animated UIImage
let jeremyGif = UIImage.gifWithName("jeremy")

// Use the UIImage in your UIImageView
let imageView = UIImageView(image: jeremyGif)