Gifu/README.md

72 lines
3.1 KiB
Markdown
Raw Normal View History

2015-12-02 22:08:05 +00:00
# ![Gifu](https://db.tt/mZ1iMNXO)
2014-09-07 21:48:09 +00:00
2016-05-28 19:49:49 +00:00
[![GitHub release](https://img.shields.io/github/release/kaishin/Gifu.svg?maxAge=2592000)](https://github.com/kaishin/Gifu/releases/latest) [![Travis](https://travis-ci.org/kaishin/Gifu.svg?branch=master)](https://travis-ci.org/kaishin/Gifu) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![Join the chat at https://gitter.im/kaishin/gifu](https://badges.gitter.im/kaishin/gifu.svg)](https://gitter.im/kaishin/gifu)
2016-01-31 12:00:48 +00:00
Adds performant animated GIF support to UIKit. If you're looking for the Japanese prefecture, click [here](https://goo.gl/maps/CCeAc).
2014-09-06 14:17:20 +00:00
2016-09-25 18:12:56 +00:00
**Swift 3.0** support is in progress on the [swift3](https://github.com/kaishin/Gifu/tree/swift3) branch.
**Swift 2.3** support is on the [swift2.3](https://github.com/kaishin/Gifu/tree/swift2.3) branch. **This branch will not be getting any future updates**.
2016-06-19 10:06:44 +00:00
#### How?
2014-09-07 22:36:05 +00:00
Gifu uses a `UIImageView` subclass and an animator that keeps track of frames and their durations.
2014-09-07 21:45:51 +00:00
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):
2014-09-07 21:45:51 +00:00
<img src="https://db.tt/ZLfx23hg" width="300" />
2014-09-07 21:45:51 +00:00
2014-12-08 22:22:46 +00:00
#### Install
2015-12-02 22:47:47 +00:00
#### [Carthage](https://github.com/Carthage/Carthage)
2014-12-08 22:22:46 +00:00
2015-12-02 22:47:47 +00:00
- Add the following to your Cartfile: `github "kaishin/Gifu"`
- Then run `carthage update`
- Follow the current instructions in [Carthage's README][carthage-installation]
for up to date installation instructions.
2014-09-07 21:45:51 +00:00
2015-12-02 22:47:47 +00:00
[carthage-installation]: https://github.com/Carthage/Carthage#adding-frameworks-to-an-application
#### [CocoaPods](http://cocoapods.org)
- Add the following to your [Podfile](http://guides.cocoapods.org/using/the-podfile.html): `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.
2014-12-08 22:22:46 +00:00
#### Usage
2014-09-07 21:45:51 +00:00
Start by instantiating an `AnimatableImageView` either in code or Interface Builder, then call `animateWithImage(named:)` or `animateWithImageData(data:)` on it.
2014-09-07 21:45:51 +00:00
```swift
let imageView = AnimatableImageView(frame: CGRect(...))
imageView.animateWithImage(named: "mugen.gif")
2014-09-07 21:45:51 +00:00
```
You can stop the animation anytime using `imageView.stopAnimatingGIF()`, and resume
it using `imageView.startAnimatingGIF()`.
2014-09-07 22:48:47 +00:00
The `isAnimatingGIF()` method returns the current animation state of the view if it has an animatable image.
2014-09-11 21:26:38 +00:00
See the [full documentation](http://kaishin.github.io/Gifu/).
2015-12-02 22:32:02 +00:00
2014-11-04 10:28:43 +00:00
#### Demo App
Clone or download the repository and open `Gifu.xcworkspace` to check out the demo app.
2014-09-07 22:48:47 +00:00
#### Compatibility
2015-12-02 22:32:02 +00:00
- iOS 8+
2014-09-07 22:36:05 +00:00
2014-12-12 22:29:10 +00:00
#### Misc
2014-09-07 21:45:51 +00:00
- The font used in the logo is [Azuki](http://www.myfonts.com/fonts/bluevinyl/azuki/)
2014-09-10 19:41:13 +00:00
- The characters used in the icon and example image in the demo are from [Samurai Champloo](https://en.wikipedia.org/wiki/Samurai_Champloo).
2014-09-10 19:44:28 +00:00
2014-09-07 21:45:51 +00:00
#### License
See LICENSE.