import ImageIO // 导入
func getFirstImageWithGIF() -> UIImage {
let gifPathSource = NSBundle.mainBundle().pathForResource("22", ofType: "gif")
let data = NSData.init(contentsOfFile: gifPathSource!)
let source = CGImageSourceCreateWithData(data!, nil)
let count = CGImageSourceGetCount(source!)
var tmpArray = [UIImage]()
for i in 0..<count {
let imageRef = CGImageSourceCreateImageAtIndex(source!, i, nil)
let image = UIImage.init(CGImage: imageRef!, scale: CGFloat(i), orientation: UIImageOrientation.Up)
tmpArray.append(image)
}
return tmpArray.first!
}