编辑代码

let iv = self.view.viewithTag(4)! as! UIImgeView

let img = UIImage.animgatedImageNamed("frame-",duration: 0.5)
iv.image = img
var imgs :Array<UIImage> = []
for i in 1...19 {
    let img = UIImage(named: "frame-\(i).png")!
    imgs.append(img)
}
let imgView = self.viewithTage(4) as! UIImageView
imgView.animationImages = imgs
imgView.animationDuration = 0.8
imgView.startAnimating()