A small UIImage
extension with gif support.
Import the Gif.swift
in your project and do the following:
// jeremy.gif
var url = NSBundle.mainBundle().URLForResource("jeremy", withExtension: "gif")
var imageData = NSData(contentsOfURL: url)
// Returns an animated UIImage
UIImage.animatedImageWithData(imageData)
Easy, it does the following:
- Find out the duration of every frame
- Find the greatest common divisor
- Add frames accordingly to the greatest common divisor to an array
- Create an animated UIImage with the frames
This project is heavily inspired by uiimage-from-animated-gif. Kudos to @mayoff. 👍
This repository is licensed under the MIT license, more under LICENSE.