Bump to v2.0

This commit is contained in:
Reda Lemeden 2017-01-05 01:19:12 +01:00
parent 18a12996b8
commit 439cc1e5c5
No known key found for this signature in database
GPG Key ID: 2A4B46ECF1B02C90
24 changed files with 363 additions and 75 deletions

View File

@ -11,6 +11,7 @@
002A1BFC1D1624D0005ABBD0 /* mugen.gif in Resources */ = {isa = PBXBuildFile; fileRef = 002A1BFB1D1624D0005ABBD0 /* mugen.gif */; };
002FF5141D3A91340069CA56 /* Gifu.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A1BF91D161D33005ABBD0 /* Gifu.framework */; };
007380231B279644008DAD5C /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 007380221B279644008DAD5C /* Default-568h@2x.png */; };
00B2B8181E1DAB1C00A50D91 /* UIImageViewExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00B2B8171E1DAB1C00A50D91 /* UIImageViewExtension.swift */; };
00DD26EB1DA5968500A0F683 /* EmptyViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00DD26EA1DA5968500A0F683 /* EmptyViewController.swift */; };
9D98823D19BC69CA00B790C6 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D98823C19BC69CA00B790C6 /* AppDelegate.swift */; };
9D98823F19BC69CA00B790C6 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D98823E19BC69CA00B790C6 /* ViewController.swift */; };
@ -23,6 +24,7 @@
002A1BF91D161D33005ABBD0 /* Gifu.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Gifu.framework; path = "../../../../Library/Developer/Xcode/DerivedData/Gifu-gwslszlwadetledwfipapwloqzrw/Build/Products/Debug-iphonesimulator/Gifu.framework"; sourceTree = "<group>"; };
002A1BFB1D1624D0005ABBD0 /* mugen.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; name = mugen.gif; path = ../../../GifuTests/Images/mugen.gif; sourceTree = "<group>"; };
007380221B279644008DAD5C /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = "<group>"; };
00B2B8171E1DAB1C00A50D91 /* UIImageViewExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIImageViewExtension.swift; sourceTree = "<group>"; };
00DD26EA1DA5968500A0F683 /* EmptyViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EmptyViewController.swift; sourceTree = "<group>"; };
9D25870519BCCB0F00A55A18 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
9D98823719BC69CA00B790C6 /* Demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Demo.app; sourceTree = BUILT_PRODUCTS_DIR; };
@ -78,6 +80,7 @@
9D98825919BC69F600B790C6 /* Main.storyboard */,
9D98823E19BC69CA00B790C6 /* ViewController.swift */,
00DD26EA1DA5968500A0F683 /* EmptyViewController.swift */,
00B2B8171E1DAB1C00A50D91 /* UIImageViewExtension.swift */,
);
path = Source;
sourceTree = "<group>";
@ -120,7 +123,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0800;
LastUpgradeCheck = 0820;
ORGANIZATIONNAME = "Kaishin & Co";
TargetAttributes = {
9D98823619BC69CA00B790C6 = {
@ -170,6 +173,7 @@
files = (
00DD26EB1DA5968500A0F683 /* EmptyViewController.swift in Sources */,
9D98823F19BC69CA00B790C6 /* ViewController.swift in Sources */,
00B2B8181E1DAB1C00A50D91 /* UIImageViewExtension.swift in Sources */,
9D98823D19BC69CA00B790C6 /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
@ -190,8 +194,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@ -234,8 +240,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";

View File

@ -1,7 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11201" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="E4d-Zb-hdl">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16C67" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="vXZ-lx-hvc">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
@ -19,6 +22,7 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="252" text="Tap the image to pause/resume. Swipe to change GIF." textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="wsv-cU-WO5">
<rect key="frame" x="95" y="79.5" width="185.5" height="29"/>
<constraints>
<constraint firstAttribute="width" relation="lessThanOrEqual" constant="200" id="73c-sg-Egr"/>
</constraints>
@ -27,6 +31,7 @@
<nil key="highlightedColor"/>
</label>
<imageView clipsSubviews="YES" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" placeholderIntrinsicWidth="600" placeholderIntrinsicHeight="300" translatesAutoresizingMaskIntoConstraints="NO" id="FSz-xF-Xds" customClass="GIFImageView" customModule="Gifu">
<rect key="frame" x="0.0" y="158.5" width="375" height="300"/>
<gestureRecognizers/>
<constraints>
<constraint firstAttribute="width" secondItem="FSz-xF-Xds" secondAttribute="height" multiplier="5:4" id="EOH-hn-KxM"/>
@ -39,6 +44,7 @@
</connections>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="252" text="Gifu" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="c8Y-41-BaC">
<rect key="frame" x="170.5" y="55" width="34" height="20.5"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
<color key="textColor" red="0.99144423007965088" green="0.56549066305160522" blue="0.033751130104064941" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
@ -119,6 +125,7 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<imageView clipsSubviews="YES" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" placeholderIntrinsicWidth="600" placeholderIntrinsicHeight="300" translatesAutoresizingMaskIntoConstraints="NO" id="Us4-12-3Mt" customClass="GIFImageView" customModule="Gifu">
<rect key="frame" x="0.0" y="146" width="375" height="300"/>
<gestureRecognizers/>
<constraints>
<constraint firstAttribute="width" secondItem="Us4-12-3Mt" secondAttribute="height" multiplier="5:4" id="VBo-I2-vrW"/>

View File

@ -0,0 +1,28 @@
import UIKit
import Gifu
extension UIImageView: GIFAnimatable {
private struct AssociatedKeys {
static var AnimatorKey = "gifu.animator.key"
}
override open func display(_ layer: CALayer) {
updateImageIfNeeded()
}
public var animator: Animator? {
get {
guard let animator = objc_getAssociatedObject(self, &AssociatedKeys.AnimatorKey) as? Animator else {
let animator = Animator(withDelegate: self)
self.animator = animator
return animator
}
return animator
}
set {
objc_setAssociatedObject(self, &AssociatedKeys.AnimatorKey, newValue as Animator?, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
}
}
}

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Gifu"
s.version = "2.0.0-rc"
s.version = "2.0.0"
s.summary = "High-performance animated GIF support for iOS "
s.homepage = "https://github.com/kaishin/Gifu"
s.social_media_url = "http://twitter.com/kaishin"

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "0820"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View File

@ -4,9 +4,7 @@
Gifu adds protocol-based, performance-aware animated GIF support to UIKit. (It's also a [prefecture in Japan](https://goo.gl/maps/CCeAc)).
**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**.
⚠ What follows applies to the yet unreleased `2.0` on `master`.
**Swift 2.3** support is on the [swift2.3](https://github.com/kaishin/Gifu/tree/swift2.3) branch which will not be getting any future updates.
## Install
@ -27,7 +25,7 @@ for up to date installation instructions.
## How It Works
`Gifu` does not force you to use the built-in `GIFImageView` subclass. The `Animator` does the heavy-lifting, while the `GIFAnimatable` protocol exposes the functionality to the view classes that conform to it, using protocol extensions.
`Gifu` does not require using the built-in `GIFImageView` subclass. The `Animator` class does the heavy-lifting, while the `GIFAnimatable` protocol exposes the functionality to the view classes that conform to it, using protocol extensions.
The `Animator` has a `FrameStore` that only keeps a limited number of frames in-memory, effectively creating a buffer for the animation without consuming all the available memory. This approach makes loading large GIFs a lot more resource-friendly.
@ -41,7 +39,7 @@ containing 10 frames, Gifu will load the current frame (red), buffer the next tw
There are two options that should cover any situation:
- Use the built-in `GIFImageView` subclass if you don't need to combine GIF support with another image library.
- If you need more flexibility and composability, make your class conform to `GIFAnimatable`. In practice, any `UIView` subclass would do, since you get most of the required properties for free. For best results, make your `UIImageView` subclass conform to `GIFAnimatable` to get other niceties such as intrinsic content size.
- If you need more flexibility and composability, make your class conform to `GIFAnimatable`. In practice, any `UIView` subclass would do, since you get most of the required properties for free. For best results, make your `UIImageView` subclass conform to `GIFAnimatable` to get access to other features such as intrinsic content size.
### GIFAnimatable
@ -82,7 +80,38 @@ class CustomAnimatedView: UIView, GIFAnimatable {
}
~~~
Keep in mind that you need to have control over the class implementing `GIFAnimatable` since you cannot add the stored `Animator` property in an extension.
You can also make `UIKit` classes conform using associated objects may you wish:
~~~swift
import UIKit
import Gifu
extension UIImageView: GIFAnimatable {
private struct AssociatedKeys {
static var AnimatorKey = "gifu.animator.key"
}
override open func display(_ layer: CALayer) {
updateImageIfNeeded()
}
public var animator: Animator? {
get {
guard let animator = objc_getAssociatedObject(self, &AssociatedKeys.AnimatorKey) as? Animator else {
let animator = Animator(withDelegate: self)
self.animator = animator
return animator
}
return animator
}
set {
objc_setAssociatedObject(self, &AssociatedKeys.AnimatorKey, newValue as Animator?, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
}
}
}
~~~
### Examples
@ -129,7 +158,6 @@ Clone or download the repository and open `Gifu.xcworkspace` to check out the de
See the [full API documentation](http://kaishin.github.io/Gifu/).
## Compatibility
- iOS 9.0+

View File

@ -13,4 +13,3 @@ public class GIFImageView: UIImageView, GIFAnimatable {
updateImageIfNeeded()
}
}

View File

@ -15,11 +15,11 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.0</string>
<string>2.0.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>121</string>
<string>124</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>

View File

@ -128,7 +128,7 @@
</section>
<section id="footer">
<p>2015 © Reda Lemeden. See LICENSE for more details.</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.2</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
</div>

View File

@ -127,7 +127,7 @@
</section>
<section id="footer">
<p>2015 © Reda Lemeden. See LICENSE for more details.</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.2</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
</div>

View File

@ -149,7 +149,7 @@
</section>
<section id="footer">
<p>2015 © Reda Lemeden. See LICENSE for more details.</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.2</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
</div>

View File

@ -124,7 +124,7 @@
</section>
<section id="footer">
<p>2015 © Reda Lemeden. See LICENSE for more details.</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.2</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
</div>

View File

@ -215,6 +215,36 @@
</div>
<div class="task-group">
<ul>
<li class="item">
<div>
<code>
<a name="/s:vE4GifuPS_13GIFAnimatable15gifLoopDurationSd"></a>
<a name="//apple_ref/swift/Property/gifLoopDuration" class="dashAnchor"></a>
<a class="token" href="#/s:vE4GifuPS_13GIFAnimatable15gifLoopDurationSd">gifLoopDuration</a>
</code>
<span class="declaration-note">
Extension method
</span>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Total duration of one animation loop</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">gifLoopDuration</span><span class="p">:</span> <span class="kt">TimeInterval</span></code></pre>
</div>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
@ -308,9 +338,9 @@
<li class="item">
<div>
<code>
<a name="/s:FE4GifuPS_13GIFAnimatable7animateFT12withGIFNamedSS_T_"></a>
<a name="//apple_ref/swift/Method/animate(withGIFNamed:)" class="dashAnchor"></a>
<a class="token" href="#/s:FE4GifuPS_13GIFAnimatable7animateFT12withGIFNamedSS_T_">animate(withGIFNamed:)</a>
<a name="/s:FE4GifuPS_13GIFAnimatable7animateFT12withGIFNamedSS9loopCountSi_T_"></a>
<a name="//apple_ref/swift/Method/animate(withGIFNamed:loopCount:)" class="dashAnchor"></a>
<a class="token" href="#/s:FE4GifuPS_13GIFAnimatable7animateFT12withGIFNamedSS9loopCountSi_T_">animate(withGIFNamed:loopCount:)</a>
</code>
<span class="declaration-note">
Extension method
@ -328,7 +358,7 @@
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">animate</span><span class="p">(</span><span class="n">withGIFNamed</span> <span class="nv">imageName</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span></code></pre>
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">animate</span><span class="p">(</span><span class="n">withGIFNamed</span> <span class="nv">imageName</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">loopCount</span><span class="p">:</span> <span class="kt">Int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">)</span></code></pre>
</div>
</div>
@ -349,6 +379,19 @@
</div>
</td>
</tr>
<tr>
<td>
<code>
<em>loopCount</em>
</code>
</td>
<td>
<div>
<p>Desired number of loops, &lt;= 0 for infinite loop.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
@ -358,9 +401,9 @@
<li class="item">
<div>
<code>
<a name="/s:FE4GifuPS_13GIFAnimatable7animateFT11withGIFDataV10Foundation4Data_T_"></a>
<a name="//apple_ref/swift/Method/animate(withGIFData:)" class="dashAnchor"></a>
<a class="token" href="#/s:FE4GifuPS_13GIFAnimatable7animateFT11withGIFDataV10Foundation4Data_T_">animate(withGIFData:)</a>
<a name="/s:FE4GifuPS_13GIFAnimatable7animateFT11withGIFDataV10Foundation4Data9loopCountSi_T_"></a>
<a name="//apple_ref/swift/Method/animate(withGIFData:loopCount:)" class="dashAnchor"></a>
<a class="token" href="#/s:FE4GifuPS_13GIFAnimatable7animateFT11withGIFDataV10Foundation4Data9loopCountSi_T_">animate(withGIFData:loopCount:)</a>
</code>
<span class="declaration-note">
Extension method
@ -378,7 +421,7 @@
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">animate</span><span class="p">(</span><span class="n">withGIFData</span> <span class="nv">imageData</span><span class="p">:</span> <span class="kt">Data</span><span class="p">)</span></code></pre>
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">animate</span><span class="p">(</span><span class="n">withGIFData</span> <span class="nv">imageData</span><span class="p">:</span> <span class="kt">Data</span><span class="p">,</span> <span class="nv">loopCount</span><span class="p">:</span> <span class="kt">Int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">)</span></code></pre>
</div>
</div>
@ -399,6 +442,19 @@
</div>
</td>
</tr>
<tr>
<td>
<code>
<em>loopCount</em>
</code>
</td>
<td>
<div>
<p>Desired number of loops, &lt;= 0 for infinite loop.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
@ -408,9 +464,9 @@
<li class="item">
<div>
<code>
<a name="/s:FE4GifuPS_13GIFAnimatable19prepareForAnimationFT12withGIFNamedSS_T_"></a>
<a name="//apple_ref/swift/Method/prepareForAnimation(withGIFNamed:)" class="dashAnchor"></a>
<a class="token" href="#/s:FE4GifuPS_13GIFAnimatable19prepareForAnimationFT12withGIFNamedSS_T_">prepareForAnimation(withGIFNamed:)</a>
<a name="/s:FE4GifuPS_13GIFAnimatable19prepareForAnimationFT12withGIFNamedSS9loopCountSi17completionHandlerGSqFT_T___T_"></a>
<a name="//apple_ref/swift/Method/prepareForAnimation(withGIFNamed:loopCount:completionHandler:)" class="dashAnchor"></a>
<a class="token" href="#/s:FE4GifuPS_13GIFAnimatable19prepareForAnimationFT12withGIFNamedSS9loopCountSi17completionHandlerGSqFT_T___T_">prepareForAnimation(withGIFNamed:loopCount:completionHandler:)</a>
</code>
<span class="declaration-note">
Extension method
@ -428,7 +484,7 @@
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">prepareForAnimation</span><span class="p">(</span><span class="n">withGIFNamed</span> <span class="nv">imageName</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span></code></pre>
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">prepareForAnimation</span><span class="p">(</span><span class="n">withGIFNamed</span> <span class="nv">imageName</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">loopCount</span><span class="p">:</span> <span class="kt">Int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> <span class="nv">completionHandler</span><span class="p">:</span> <span class="p">((</span><span class="kt">Void</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Void</span><span class="p">)?</span> <span class="o">=</span> <span class="o">.</span><span class="k">none</span><span class="p">)</span></code></pre>
</div>
</div>
@ -449,6 +505,19 @@
</div>
</td>
</tr>
<tr>
<td>
<code>
<em>loopCount</em>
</code>
</td>
<td>
<div>
<p>Desired number of loops, &lt;= 0 for infinite loop.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
@ -458,9 +527,9 @@
<li class="item">
<div>
<code>
<a name="/s:FE4GifuPS_13GIFAnimatable19prepareForAnimationFT11withGIFDataV10Foundation4Data_T_"></a>
<a name="//apple_ref/swift/Method/prepareForAnimation(withGIFData:)" class="dashAnchor"></a>
<a class="token" href="#/s:FE4GifuPS_13GIFAnimatable19prepareForAnimationFT11withGIFDataV10Foundation4Data_T_">prepareForAnimation(withGIFData:)</a>
<a name="/s:FE4GifuPS_13GIFAnimatable19prepareForAnimationFT11withGIFDataV10Foundation4Data9loopCountSi17completionHandlerGSqFT_T___T_"></a>
<a name="//apple_ref/swift/Method/prepareForAnimation(withGIFData:loopCount:completionHandler:)" class="dashAnchor"></a>
<a class="token" href="#/s:FE4GifuPS_13GIFAnimatable19prepareForAnimationFT11withGIFDataV10Foundation4Data9loopCountSi17completionHandlerGSqFT_T___T_">prepareForAnimation(withGIFData:loopCount:completionHandler:)</a>
</code>
<span class="declaration-note">
Extension method
@ -478,7 +547,7 @@
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">prepareForAnimation</span><span class="p">(</span><span class="n">withGIFData</span> <span class="nv">imageData</span><span class="p">:</span> <span class="kt">Data</span><span class="p">)</span></code></pre>
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">prepareForAnimation</span><span class="p">(</span><span class="n">withGIFData</span> <span class="nv">imageData</span><span class="p">:</span> <span class="kt">Data</span><span class="p">,</span> <span class="nv">loopCount</span><span class="p">:</span> <span class="kt">Int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> <span class="nv">completionHandler</span><span class="p">:</span> <span class="p">((</span><span class="kt">Void</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Void</span><span class="p">)?</span> <span class="o">=</span> <span class="o">.</span><span class="k">none</span><span class="p">)</span></code></pre>
</div>
</div>
@ -499,6 +568,19 @@
</div>
</td>
</tr>
<tr>
<td>
<code>
<em>loopCount</em>
</code>
</td>
<td>
<div>
<p>Desired number of loops, &lt;= 0 for infinite loop.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
@ -731,7 +813,7 @@
</section>
<section id="footer">
<p>2015 © Reda Lemeden. See LICENSE for more details.</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.2</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
</div>

View File

@ -102,7 +102,7 @@
</section>
<section id="footer">
<p>2015 © Reda Lemeden. See LICENSE for more details.</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.2</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
</div>

View File

@ -128,7 +128,7 @@
</section>
<section id="footer">
<p>2015 © Reda Lemeden. See LICENSE for more details.</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.2</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
</div>

View File

@ -127,7 +127,7 @@
</section>
<section id="footer">
<p>2015 © Reda Lemeden. See LICENSE for more details.</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.2</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
</div>

View File

@ -149,7 +149,7 @@
</section>
<section id="footer">
<p>2015 © Reda Lemeden. See LICENSE for more details.</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.2</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
</div>

View File

@ -124,7 +124,7 @@
</section>
<section id="footer">
<p>2015 © Reda Lemeden. See LICENSE for more details.</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.2</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
</div>

View File

@ -215,6 +215,36 @@
</div>
<div class="task-group">
<ul>
<li class="item">
<div>
<code>
<a name="/s:vE4GifuPS_13GIFAnimatable15gifLoopDurationSd"></a>
<a name="//apple_ref/swift/Property/gifLoopDuration" class="dashAnchor"></a>
<a class="token" href="#/s:vE4GifuPS_13GIFAnimatable15gifLoopDurationSd">gifLoopDuration</a>
</code>
<span class="declaration-note">
Extension method
</span>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Total duration of one animation loop</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">gifLoopDuration</span><span class="p">:</span> <span class="kt">TimeInterval</span></code></pre>
</div>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
@ -308,9 +338,9 @@
<li class="item">
<div>
<code>
<a name="/s:FE4GifuPS_13GIFAnimatable7animateFT12withGIFNamedSS_T_"></a>
<a name="//apple_ref/swift/Method/animate(withGIFNamed:)" class="dashAnchor"></a>
<a class="token" href="#/s:FE4GifuPS_13GIFAnimatable7animateFT12withGIFNamedSS_T_">animate(withGIFNamed:)</a>
<a name="/s:FE4GifuPS_13GIFAnimatable7animateFT12withGIFNamedSS9loopCountSi_T_"></a>
<a name="//apple_ref/swift/Method/animate(withGIFNamed:loopCount:)" class="dashAnchor"></a>
<a class="token" href="#/s:FE4GifuPS_13GIFAnimatable7animateFT12withGIFNamedSS9loopCountSi_T_">animate(withGIFNamed:loopCount:)</a>
</code>
<span class="declaration-note">
Extension method
@ -328,7 +358,7 @@
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">animate</span><span class="p">(</span><span class="n">withGIFNamed</span> <span class="nv">imageName</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span></code></pre>
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">animate</span><span class="p">(</span><span class="n">withGIFNamed</span> <span class="nv">imageName</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">loopCount</span><span class="p">:</span> <span class="kt">Int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">)</span></code></pre>
</div>
</div>
@ -349,6 +379,19 @@
</div>
</td>
</tr>
<tr>
<td>
<code>
<em>loopCount</em>
</code>
</td>
<td>
<div>
<p>Desired number of loops, &lt;= 0 for infinite loop.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
@ -358,9 +401,9 @@
<li class="item">
<div>
<code>
<a name="/s:FE4GifuPS_13GIFAnimatable7animateFT11withGIFDataV10Foundation4Data_T_"></a>
<a name="//apple_ref/swift/Method/animate(withGIFData:)" class="dashAnchor"></a>
<a class="token" href="#/s:FE4GifuPS_13GIFAnimatable7animateFT11withGIFDataV10Foundation4Data_T_">animate(withGIFData:)</a>
<a name="/s:FE4GifuPS_13GIFAnimatable7animateFT11withGIFDataV10Foundation4Data9loopCountSi_T_"></a>
<a name="//apple_ref/swift/Method/animate(withGIFData:loopCount:)" class="dashAnchor"></a>
<a class="token" href="#/s:FE4GifuPS_13GIFAnimatable7animateFT11withGIFDataV10Foundation4Data9loopCountSi_T_">animate(withGIFData:loopCount:)</a>
</code>
<span class="declaration-note">
Extension method
@ -378,7 +421,7 @@
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">animate</span><span class="p">(</span><span class="n">withGIFData</span> <span class="nv">imageData</span><span class="p">:</span> <span class="kt">Data</span><span class="p">)</span></code></pre>
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">animate</span><span class="p">(</span><span class="n">withGIFData</span> <span class="nv">imageData</span><span class="p">:</span> <span class="kt">Data</span><span class="p">,</span> <span class="nv">loopCount</span><span class="p">:</span> <span class="kt">Int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">)</span></code></pre>
</div>
</div>
@ -399,6 +442,19 @@
</div>
</td>
</tr>
<tr>
<td>
<code>
<em>loopCount</em>
</code>
</td>
<td>
<div>
<p>Desired number of loops, &lt;= 0 for infinite loop.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
@ -408,9 +464,9 @@
<li class="item">
<div>
<code>
<a name="/s:FE4GifuPS_13GIFAnimatable19prepareForAnimationFT12withGIFNamedSS_T_"></a>
<a name="//apple_ref/swift/Method/prepareForAnimation(withGIFNamed:)" class="dashAnchor"></a>
<a class="token" href="#/s:FE4GifuPS_13GIFAnimatable19prepareForAnimationFT12withGIFNamedSS_T_">prepareForAnimation(withGIFNamed:)</a>
<a name="/s:FE4GifuPS_13GIFAnimatable19prepareForAnimationFT12withGIFNamedSS9loopCountSi17completionHandlerGSqFT_T___T_"></a>
<a name="//apple_ref/swift/Method/prepareForAnimation(withGIFNamed:loopCount:completionHandler:)" class="dashAnchor"></a>
<a class="token" href="#/s:FE4GifuPS_13GIFAnimatable19prepareForAnimationFT12withGIFNamedSS9loopCountSi17completionHandlerGSqFT_T___T_">prepareForAnimation(withGIFNamed:loopCount:completionHandler:)</a>
</code>
<span class="declaration-note">
Extension method
@ -428,7 +484,7 @@
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">prepareForAnimation</span><span class="p">(</span><span class="n">withGIFNamed</span> <span class="nv">imageName</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span></code></pre>
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">prepareForAnimation</span><span class="p">(</span><span class="n">withGIFNamed</span> <span class="nv">imageName</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">loopCount</span><span class="p">:</span> <span class="kt">Int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> <span class="nv">completionHandler</span><span class="p">:</span> <span class="p">((</span><span class="kt">Void</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Void</span><span class="p">)?</span> <span class="o">=</span> <span class="o">.</span><span class="k">none</span><span class="p">)</span></code></pre>
</div>
</div>
@ -449,6 +505,19 @@
</div>
</td>
</tr>
<tr>
<td>
<code>
<em>loopCount</em>
</code>
</td>
<td>
<div>
<p>Desired number of loops, &lt;= 0 for infinite loop.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
@ -458,9 +527,9 @@
<li class="item">
<div>
<code>
<a name="/s:FE4GifuPS_13GIFAnimatable19prepareForAnimationFT11withGIFDataV10Foundation4Data_T_"></a>
<a name="//apple_ref/swift/Method/prepareForAnimation(withGIFData:)" class="dashAnchor"></a>
<a class="token" href="#/s:FE4GifuPS_13GIFAnimatable19prepareForAnimationFT11withGIFDataV10Foundation4Data_T_">prepareForAnimation(withGIFData:)</a>
<a name="/s:FE4GifuPS_13GIFAnimatable19prepareForAnimationFT11withGIFDataV10Foundation4Data9loopCountSi17completionHandlerGSqFT_T___T_"></a>
<a name="//apple_ref/swift/Method/prepareForAnimation(withGIFData:loopCount:completionHandler:)" class="dashAnchor"></a>
<a class="token" href="#/s:FE4GifuPS_13GIFAnimatable19prepareForAnimationFT11withGIFDataV10Foundation4Data9loopCountSi17completionHandlerGSqFT_T___T_">prepareForAnimation(withGIFData:loopCount:completionHandler:)</a>
</code>
<span class="declaration-note">
Extension method
@ -478,7 +547,7 @@
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">prepareForAnimation</span><span class="p">(</span><span class="n">withGIFData</span> <span class="nv">imageData</span><span class="p">:</span> <span class="kt">Data</span><span class="p">)</span></code></pre>
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">prepareForAnimation</span><span class="p">(</span><span class="n">withGIFData</span> <span class="nv">imageData</span><span class="p">:</span> <span class="kt">Data</span><span class="p">,</span> <span class="nv">loopCount</span><span class="p">:</span> <span class="kt">Int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> <span class="nv">completionHandler</span><span class="p">:</span> <span class="p">((</span><span class="kt">Void</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Void</span><span class="p">)?</span> <span class="o">=</span> <span class="o">.</span><span class="k">none</span><span class="p">)</span></code></pre>
</div>
</div>
@ -499,6 +568,19 @@
</div>
</td>
</tr>
<tr>
<td>
<code>
<em>loopCount</em>
</code>
</td>
<td>
<div>
<p>Desired number of loops, &lt;= 0 for infinite loop.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
@ -731,7 +813,7 @@
</section>
<section id="footer">
<p>2015 © Reda Lemeden. See LICENSE for more details.</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.2</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
</div>

View File

@ -102,7 +102,7 @@
</section>
<section id="footer">
<p>2015 © Reda Lemeden. See LICENSE for more details.</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.2</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
</div>

View File

@ -58,13 +58,11 @@
<a href='#img-src-https-github-com-kaishin-gifu-raw-master-header-gif-alt-logo' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h1 id='img-src-https-github-com-kaishin-gifu-raw-master-header-gif-alt-logo'><img src="https://github.com/kaishin/Gifu/raw/master/header.gif" alt="Logo"></h1>
<p><a href="https://github.com/kaishin/Gifu/releases/latest"><img src="https://img.shields.io/github/release/kaishin/Gifu.svg?maxAge=2592000" alt="GitHub release"></a> <a href="https://travis-ci.org/kaishin/Gifu"><img src="https://travis-ci.org/kaishin/Gifu.svg?branch=master" alt="Travis"></a> <a href="https://github.com/Carthage/Carthage"><img src="https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat" alt="Carthage compatible"></a> <a href="https://gitter.im/kaishin/gifu"><img src="https://badges.gitter.im/kaishin/gifu.svg" alt="Join the chat at https://gitter.im/kaishin/gifu"></a> <img src="https://img.shields.io/badge/Swift-3.0.x-orange.svg" alt="Swift 3.0.x"> <img src="https://img.shields.io/badge/platforms-iOS-lightgrey.svg" alt="platforms"></p>
<p><a href="https://github.com/kaishin/Gifu/releases/latest"><img src="https://img.shields.io/github/release/kaishin/Gifu.svg?maxAge=2592000" alt="GitHub release"></a> <img src="https://www.bitrise.io/app/a0eae2c9b6aa754c.svg?token=dDlRyPi2aOlZnvbl4kL8Kw&amp;branch=master" alt="Bitrise"> <a href="https://github.com/Carthage/Carthage"><img src="https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat" alt="Carthage compatible"></a> <a href="https://gitter.im/kaishin/gifu"><img src="https://badges.gitter.im/kaishin/gifu.svg" alt="Join the chat at https://gitter.im/kaishin/gifu"></a> <img src="https://img.shields.io/badge/Swift-3.0.x-orange.svg" alt="Swift 3.0.x"> <img src="https://img.shields.io/badge/platforms-iOS-lightgrey.svg" alt="platforms"></p>
<p>Gifu adds protocol-based, performance-aware animated GIF support to UIKit. (It&rsquo;s also a <a href="https://goo.gl/maps/CCeAc">prefecture in Japan</a>).</p>
<p><strong>Swift 2.3</strong> support is on the <a href="https://github.com/kaishin/Gifu/tree/swift2.3">swift2.3</a> branch. <strong>This branch will not be getting any future updates</strong>.</p>
<p>⚠ What follows applies to the yet unreleased <code>2.0</code> on <code>master</code>.</p>
<p><strong>Swift 2.3</strong> support is on the <a href="https://github.com/kaishin/Gifu/tree/swift2.3">swift2.3</a> branch which will not be getting any future updates.</p>
<a href='#install' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h2 id='install'>Install</h2>
<a href='#a-href-https-github-com-carthage-carthage-carthage-a' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h3 id='a-href-https-github-com-carthage-carthage-carthage-a'><a href="https://github.com/Carthage/Carthage">Carthage</a></h3>
@ -83,7 +81,7 @@ for up to date installation instructions.</li>
</ul>
<a href='#how-it-works' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h2 id='how-it-works'>How It Works</h2>
<p><code>Gifu</code> does not force you to use the built-in <code>GIFImageView</code> subclass. The <code>Animator</code> does the heavy-lifting, while the <code>GIFAnimatable</code> protocol exposes the functionality to the view classes that conform to it, using protocol extensions.</p>
<p><code>Gifu</code> does not require using the built-in <code>GIFImageView</code> subclass. The <code>Animator</code> class does the heavy-lifting, while the <code>GIFAnimatable</code> protocol exposes the functionality to the view classes that conform to it, using protocol extensions.</p>
<p>The <code>Animator</code> has a <code>FrameStore</code> that only keeps a limited number of frames in-memory, effectively creating a buffer for the animation without consuming all the available memory. This approach makes loading large GIFs a lot more resource-friendly.</p>
@ -97,7 +95,7 @@ containing 10 frames, Gifu will load the current frame (red), buffer the next tw
<ul>
<li>Use the built-in <code>GIFImageView</code> subclass if you don&rsquo;t need to combine GIF support with another image library.</li>
<li>If you need more flexibility and composability, make your class conform to <code>GIFAnimatable</code>. In practice, any <code>UIView</code> subclass would do, since you get most of the required properties for free. For best results, make your <code>UIImageView</code> subclass conform to <code>GIFAnimatable</code> to get other niceties such as intrinsic content size.</li>
<li>If you need more flexibility and composability, make your class conform to <code>GIFAnimatable</code>. In practice, any <code>UIView</code> subclass would do, since you get most of the required properties for free. For best results, make your <code>UIImageView</code> subclass conform to <code>GIFAnimatable</code> to get access to other features such as intrinsic content size.</li>
</ul>
<a href='#gifanimatable' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h3 id='gifanimatable'>GIFAnimatable</h3>
@ -136,7 +134,36 @@ containing 10 frames, Gifu will load the current frame (red), buffer the next tw
<span class="p">}</span>
</code></pre>
<p>Keep in mind that you need to have control over the class implementing <code>GIFAnimatable</code> since you cannot add the stored <code>Animator</code> property in an extension.</p>
<p>You can also make <code>UIKit</code> classes conform using associated objects may you wish:</p>
<pre class="highlight swift"><code><span class="kd">import</span> <span class="kt">UIKit</span>
<span class="kd">import</span> <span class="kt">Gifu</span>
<span class="kd">extension</span> <span class="kt">UIImageView</span><span class="p">:</span> <span class="kt">GIFAnimatable</span> <span class="p">{</span>
<span class="kd">private</span> <span class="kd">struct</span> <span class="kt">AssociatedKeys</span> <span class="p">{</span>
<span class="kd">static</span> <span class="k">var</span> <span class="nv">AnimatorKey</span> <span class="o">=</span> <span class="s">"gifu.animator.key"</span>
<span class="p">}</span>
<span class="k">override</span> <span class="n">open</span> <span class="kd">func</span> <span class="nf">display</span><span class="p">(</span><span class="n">_</span> <span class="nv">layer</span><span class="p">:</span> <span class="kt">CALayer</span><span class="p">)</span> <span class="p">{</span>
<span class="nf">updateImageIfNeeded</span><span class="p">()</span>
<span class="p">}</span>
<span class="kd">public</span> <span class="k">var</span> <span class="nv">animator</span><span class="p">:</span> <span class="kt">Animator</span><span class="p">?</span> <span class="p">{</span>
<span class="k">get</span> <span class="p">{</span>
<span class="k">guard</span> <span class="k">let</span> <span class="nv">animator</span> <span class="o">=</span> <span class="nf">objc_getAssociatedObject</span><span class="p">(</span><span class="k">self</span><span class="p">,</span> <span class="o">&amp;</span><span class="kt">AssociatedKeys</span><span class="o">.</span><span class="kt">AnimatorKey</span><span class="p">)</span> <span class="k">as?</span> <span class="kt">Animator</span> <span class="k">else</span> <span class="p">{</span>
<span class="k">let</span> <span class="nv">animator</span> <span class="o">=</span> <span class="kt">Animator</span><span class="p">(</span><span class="nv">withDelegate</span><span class="p">:</span> <span class="k">self</span><span class="p">)</span>
<span class="k">self</span><span class="o">.</span><span class="n">animator</span> <span class="o">=</span> <span class="n">animator</span>
<span class="k">return</span> <span class="n">animator</span>
<span class="p">}</span>
<span class="k">return</span> <span class="n">animator</span>
<span class="p">}</span>
<span class="k">set</span> <span class="p">{</span>
<span class="nf">objc_setAssociatedObject</span><span class="p">(</span><span class="k">self</span><span class="p">,</span> <span class="o">&amp;</span><span class="kt">AssociatedKeys</span><span class="o">.</span><span class="kt">AnimatorKey</span><span class="p">,</span> <span class="n">newValue</span> <span class="k">as</span> <span class="kt">Animator</span><span class="p">?,</span> <span class="o">.</span><span class="kt">OBJC_ASSOCIATION_RETAIN_NONATOMIC</span><span class="p">)</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
</code></pre>
<a href='#examples' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h3 id='examples'>Examples</h3>
<p>The simplest way to get started is initializing a <code>GIFAnimatable</code> class in code or in a storyboard, then calling <code>animate(:)</code> on it.</p>
@ -188,7 +215,7 @@ containing 10 frames, Gifu will load the current frame (red), buffer the next tw
</section>
<section id="footer">
<p>2015 © Reda Lemeden. See LICENSE for more details.</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.2</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
</div>

Binary file not shown.

View File

@ -58,13 +58,11 @@
<a href='#img-src-https-github-com-kaishin-gifu-raw-master-header-gif-alt-logo' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h1 id='img-src-https-github-com-kaishin-gifu-raw-master-header-gif-alt-logo'><img src="https://github.com/kaishin/Gifu/raw/master/header.gif" alt="Logo"></h1>
<p><a href="https://github.com/kaishin/Gifu/releases/latest"><img src="https://img.shields.io/github/release/kaishin/Gifu.svg?maxAge=2592000" alt="GitHub release"></a> <a href="https://travis-ci.org/kaishin/Gifu"><img src="https://travis-ci.org/kaishin/Gifu.svg?branch=master" alt="Travis"></a> <a href="https://github.com/Carthage/Carthage"><img src="https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat" alt="Carthage compatible"></a> <a href="https://gitter.im/kaishin/gifu"><img src="https://badges.gitter.im/kaishin/gifu.svg" alt="Join the chat at https://gitter.im/kaishin/gifu"></a> <img src="https://img.shields.io/badge/Swift-3.0.x-orange.svg" alt="Swift 3.0.x"> <img src="https://img.shields.io/badge/platforms-iOS-lightgrey.svg" alt="platforms"></p>
<p><a href="https://github.com/kaishin/Gifu/releases/latest"><img src="https://img.shields.io/github/release/kaishin/Gifu.svg?maxAge=2592000" alt="GitHub release"></a> <img src="https://www.bitrise.io/app/a0eae2c9b6aa754c.svg?token=dDlRyPi2aOlZnvbl4kL8Kw&amp;branch=master" alt="Bitrise"> <a href="https://github.com/Carthage/Carthage"><img src="https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat" alt="Carthage compatible"></a> <a href="https://gitter.im/kaishin/gifu"><img src="https://badges.gitter.im/kaishin/gifu.svg" alt="Join the chat at https://gitter.im/kaishin/gifu"></a> <img src="https://img.shields.io/badge/Swift-3.0.x-orange.svg" alt="Swift 3.0.x"> <img src="https://img.shields.io/badge/platforms-iOS-lightgrey.svg" alt="platforms"></p>
<p>Gifu adds protocol-based, performance-aware animated GIF support to UIKit. (It&rsquo;s also a <a href="https://goo.gl/maps/CCeAc">prefecture in Japan</a>).</p>
<p><strong>Swift 2.3</strong> support is on the <a href="https://github.com/kaishin/Gifu/tree/swift2.3">swift2.3</a> branch. <strong>This branch will not be getting any future updates</strong>.</p>
<p>⚠ What follows applies to the yet unreleased <code>2.0</code> on <code>master</code>.</p>
<p><strong>Swift 2.3</strong> support is on the <a href="https://github.com/kaishin/Gifu/tree/swift2.3">swift2.3</a> branch which will not be getting any future updates.</p>
<a href='#install' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h2 id='install'>Install</h2>
<a href='#a-href-https-github-com-carthage-carthage-carthage-a' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h3 id='a-href-https-github-com-carthage-carthage-carthage-a'><a href="https://github.com/Carthage/Carthage">Carthage</a></h3>
@ -83,7 +81,7 @@ for up to date installation instructions.</li>
</ul>
<a href='#how-it-works' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h2 id='how-it-works'>How It Works</h2>
<p><code>Gifu</code> does not force you to use the built-in <code>GIFImageView</code> subclass. The <code>Animator</code> does the heavy-lifting, while the <code>GIFAnimatable</code> protocol exposes the functionality to the view classes that conform to it, using protocol extensions.</p>
<p><code>Gifu</code> does not require using the built-in <code>GIFImageView</code> subclass. The <code>Animator</code> class does the heavy-lifting, while the <code>GIFAnimatable</code> protocol exposes the functionality to the view classes that conform to it, using protocol extensions.</p>
<p>The <code>Animator</code> has a <code>FrameStore</code> that only keeps a limited number of frames in-memory, effectively creating a buffer for the animation without consuming all the available memory. This approach makes loading large GIFs a lot more resource-friendly.</p>
@ -97,7 +95,7 @@ containing 10 frames, Gifu will load the current frame (red), buffer the next tw
<ul>
<li>Use the built-in <code>GIFImageView</code> subclass if you don&rsquo;t need to combine GIF support with another image library.</li>
<li>If you need more flexibility and composability, make your class conform to <code>GIFAnimatable</code>. In practice, any <code>UIView</code> subclass would do, since you get most of the required properties for free. For best results, make your <code>UIImageView</code> subclass conform to <code>GIFAnimatable</code> to get other niceties such as intrinsic content size.</li>
<li>If you need more flexibility and composability, make your class conform to <code>GIFAnimatable</code>. In practice, any <code>UIView</code> subclass would do, since you get most of the required properties for free. For best results, make your <code>UIImageView</code> subclass conform to <code>GIFAnimatable</code> to get access to other features such as intrinsic content size.</li>
</ul>
<a href='#gifanimatable' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h3 id='gifanimatable'>GIFAnimatable</h3>
@ -136,7 +134,36 @@ containing 10 frames, Gifu will load the current frame (red), buffer the next tw
<span class="p">}</span>
</code></pre>
<p>Keep in mind that you need to have control over the class implementing <code>GIFAnimatable</code> since you cannot add the stored <code>Animator</code> property in an extension.</p>
<p>You can also make <code>UIKit</code> classes conform using associated objects may you wish:</p>
<pre class="highlight swift"><code><span class="kd">import</span> <span class="kt">UIKit</span>
<span class="kd">import</span> <span class="kt">Gifu</span>
<span class="kd">extension</span> <span class="kt">UIImageView</span><span class="p">:</span> <span class="kt">GIFAnimatable</span> <span class="p">{</span>
<span class="kd">private</span> <span class="kd">struct</span> <span class="kt">AssociatedKeys</span> <span class="p">{</span>
<span class="kd">static</span> <span class="k">var</span> <span class="nv">AnimatorKey</span> <span class="o">=</span> <span class="s">"gifu.animator.key"</span>
<span class="p">}</span>
<span class="k">override</span> <span class="n">open</span> <span class="kd">func</span> <span class="nf">display</span><span class="p">(</span><span class="n">_</span> <span class="nv">layer</span><span class="p">:</span> <span class="kt">CALayer</span><span class="p">)</span> <span class="p">{</span>
<span class="nf">updateImageIfNeeded</span><span class="p">()</span>
<span class="p">}</span>
<span class="kd">public</span> <span class="k">var</span> <span class="nv">animator</span><span class="p">:</span> <span class="kt">Animator</span><span class="p">?</span> <span class="p">{</span>
<span class="k">get</span> <span class="p">{</span>
<span class="k">guard</span> <span class="k">let</span> <span class="nv">animator</span> <span class="o">=</span> <span class="nf">objc_getAssociatedObject</span><span class="p">(</span><span class="k">self</span><span class="p">,</span> <span class="o">&amp;</span><span class="kt">AssociatedKeys</span><span class="o">.</span><span class="kt">AnimatorKey</span><span class="p">)</span> <span class="k">as?</span> <span class="kt">Animator</span> <span class="k">else</span> <span class="p">{</span>
<span class="k">let</span> <span class="nv">animator</span> <span class="o">=</span> <span class="kt">Animator</span><span class="p">(</span><span class="nv">withDelegate</span><span class="p">:</span> <span class="k">self</span><span class="p">)</span>
<span class="k">self</span><span class="o">.</span><span class="n">animator</span> <span class="o">=</span> <span class="n">animator</span>
<span class="k">return</span> <span class="n">animator</span>
<span class="p">}</span>
<span class="k">return</span> <span class="n">animator</span>
<span class="p">}</span>
<span class="k">set</span> <span class="p">{</span>
<span class="nf">objc_setAssociatedObject</span><span class="p">(</span><span class="k">self</span><span class="p">,</span> <span class="o">&amp;</span><span class="kt">AssociatedKeys</span><span class="o">.</span><span class="kt">AnimatorKey</span><span class="p">,</span> <span class="n">newValue</span> <span class="k">as</span> <span class="kt">Animator</span><span class="p">?,</span> <span class="o">.</span><span class="kt">OBJC_ASSOCIATION_RETAIN_NONATOMIC</span><span class="p">)</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
</code></pre>
<a href='#examples' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h3 id='examples'>Examples</h3>
<p>The simplest way to get started is initializing a <code>GIFAnimatable</code> class in code or in a storyboard, then calling <code>animate(:)</code> on it.</p>
@ -188,7 +215,7 @@ containing 10 frames, Gifu will load the current frame (red), buffer the next tw
</section>
<section id="footer">
<p>2015 © Reda Lemeden. See LICENSE for more details.</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.2</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
</div>