Gifu/README.md

73 lines
2.5 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
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
2015-12-02 22:32:02 +00:00
See the [full documentation](http://kaishin.github.io/gifu/).
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-09-10 19:36:06 +00:00
#### Roadmap
2014-09-07 21:45:51 +00:00
- 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.