Gifu/README.md

65 lines
2.3 KiB
Markdown
Raw Normal View History

2014-09-10 19:28:19 +00:00
<img src="https://db.tt/mZ1iMNXO" width="100" />
2014-09-07 21:48:09 +00:00
2014-09-10 19:28:19 +00:00
Adds performant animated GIF support to UIKit, without subclassing `UIImageView`. If you're looking for the Japanese prefecture, click [here](https://goo.gl/maps/CCeAc).
2014-09-06 14:17:20 +00:00
2014-09-07 21:45:51 +00:00
#### Why?
2014-09-07 22:36:05 +00:00
2014-12-12 22:29:10 +00:00
Because Apple's `+animatedImage*` is not meant to be used for animated GIFs (loads all the full-sized frames in memory), and the few third party implementations that got it right (see [Credits](#credits)) still require you to use a `UIImageView` subclass, which is not very flexible and might clash with other application-specific functionality.
2014-09-07 21:45:51 +00:00
#### How?
2014-12-12 22:29:10 +00:00
Gifu uses a `UIImage` subclass and `UIImageView` extension written in Swift.
It relies on `CADisplayLink` to animate the view and optimizes the frames by resizing them.
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
2014-12-12 22:29:10 +00:00
Start by instantiating an `AnimatedImage`, then pass it to your `UIImageView`'s `setAnimatedImage`:
2014-09-07 21:45:51 +00:00
```swift
2014-12-12 22:29:10 +00:00
if let image = AnimatedImage.animatedImageWithName("mugen.gif") {
imageView.setAnimatedImage(image)
imageView.startAnimatingGIF()
}
2014-09-07 21:45:51 +00:00
```
2014-12-12 22:29:10 +00:00
Note that the image view will not start animating until you call `startAnimatingGIF()`
2014-11-10 22:11:43 +00:00
on it. You can stop the animation anytime using `stopAnimatingGIF()`, and resume
it using `startAnimatingGIF()`. These methods will fallback to UIKit's `startAnimating()` and `stopAnimating()`
if the image view has no animatable image.
2014-09-07 22:48:47 +00:00
2014-11-10 22:11:43 +00:00
Likewise, the `isAnimatingGIF()` method returns the current animation state of the view if it has an animatable image,
or UIKit's `isAnimating()` otherwise.
2014-09-11 21:26:38 +00:00
2014-11-04 10:28:43 +00:00
#### Demo App
2014-09-10 19:28:19 +00:00
<img src="https://db.tt/ZoUNLHGp" width="300" />
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.
2014-09-07 21:45:51 +00:00
- Write some basic tests.
2014-12-12 22:29:10 +00:00
- Add ability to pass a frame-rate argument to `startAnimatingGIF()`
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.