Go to file
Reda Lemeden d3bc2e0c27 Add empty view controller
To test initalizing a GIFImageView in code.
2016-10-06 23:59:14 +02:00
Demo Add empty view controller 2016-10-06 23:59:14 +02:00
Gifu.xcodeproj Reorganize project using Synx 2016-10-06 23:59:14 +02:00
Gifu.xcworkspace Add Swift 2.0 support 2015-10-22 19:14:35 +02:00
GifuTests Reorganize project using Synx 2016-10-06 23:59:14 +02:00
Source Reorganize project using Synx 2016-10-06 23:59:14 +02:00
Supporting Files Reorganize project using Synx 2016-10-06 23:59:14 +02:00
bin Update source to Swift 3.0 and Xcode 8 2016-10-06 23:59:14 +02:00
.gitignore Ignore docs folder 2015-12-02 22:35:07 +01:00
.jazzy.yaml Update jazzy config 2016-05-28 21:46:29 +02:00
.travis.yml Update source to Swift 3.0 and Xcode 8 2016-10-06 23:59:14 +02:00
Gifu.podspec Bump to v1.2.1 2016-05-28 20:41:37 +02:00
LICENSE Update License 2016-01-20 12:29:26 +00:00
README.md Add note about Swift 2.3 support 2016-09-25 20:12:56 +02:00

README.md

Gifu

GitHub release Travis Carthage compatible Join the chat at https://gitter.im/kaishin/gifu

Adds performant animated GIF support to UIKit. If you're looking for the Japanese prefecture, click here.

Swift 3.0 support is in progress on the swift3 branch.

Swift 2.3 support is on the swift2.3 branch. This branch will not be getting any future updates.

How?

Gifu uses a UIImageView subclass and an animator that keeps track of frames and their durations.

It uses CADisplayLink to animate the view and only keeps a limited number of resized frames in-memory, which exponentially minimizes memory usage for large GIF files (+300 frames).

The figure below summarizes how this works in practice. Given an image containing 10 frames, Gifu will load the current frame (red), pre-load the next two frames in this example (orange), and nullify all the other frames to free up memory (gray):

Install

Carthage

  • Add the following to your Cartfile: github "kaishin/Gifu"
  • Then run carthage update
  • Follow the current instructions in Carthage's README for up to date installation instructions.

CocoaPods

  • Add the following to your Podfile: pod 'Gifu'
  • You will also need to make sure you're opting into using frameworks: use_frameworks!
  • Then run pod install with CocoaPods 0.36 or newer.

Usage

Start by instantiating an AnimatableImageView either in code or Interface Builder, then call animateWithImage(named:) or animateWithImageData(data:) on it.

let imageView = AnimatableImageView(frame: CGRect(...))
imageView.animateWithImage(named: "mugen.gif")

You can stop the animation anytime using imageView.stopAnimatingGIF(), and resume it using imageView.startAnimatingGIF().

The isAnimatingGIF() method returns the current animation state of the view if it has an animatable image.

See the full documentation.

Demo App

Clone or download the repository and open Gifu.xcworkspace to check out the demo app.

Compatibility

  • iOS 8+

Misc

  • The font used in the logo is Azuki
  • The characters used in the icon and example image in the demo are from Samurai Champloo.

License

See LICENSE.