Gifu/README.md

62 lines
2.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
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
#### 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
If you use [Carthage](https://github.com/Carthage/Carthage), add this to your `cartfile`: `github "kaishin/gifu"`.
2014-09-07 21:45:51 +00:00
2014-12-08 22:22:46 +00:00
If your prefer Git submodules or want to support iOS 7, you want to add the files in `source` to your Xcode project.
#### 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
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
- iOS 7+
2014-09-07 22:36:05 +00:00
2014-09-10 19:36:06 +00:00
#### Roadmap
2014-09-07 21:45:51 +00:00
2014-12-12 22:29:10 +00:00
- Documentation.
- Add ability to set the frame-rate
2014-09-07 21:45:51 +00:00
2014-12-12 22:29:10 +00:00
#### Contributors
2014-09-07 21:45:51 +00:00
2014-12-12 22:29:10 +00:00
- [Reda Lemeden](https://github.com/kaishin)
- [Tony DiPasquale](https://github.com/tonyd256)
2014-09-07 21:45:51 +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.