Skip to content

Commit

Permalink
Add Demo
Browse files Browse the repository at this point in the history
  • Loading branch information
Reda Lemeden committed Nov 10, 2014
1 parent 4a3816c commit 0e48455
Show file tree
Hide file tree
Showing 20 changed files with 801 additions and 7 deletions.
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
*.mode1
*.mode1v3
*.mode2v3
*.perspective
*.perspectivev3
*.pbxuser
*.xccheckout
xcuserdata
build/
*.o
*.LinkFileList
*.hmap
*~.nib/
*.swp
*~
*.dat
*.dep
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<img src="https://dl.dropboxusercontent.com/u/148921/assets/logo.svg" width="100" />
<img src="https://db.tt/mZ1iMNXO" width="100" />

Adds performant animated GIF support to UIKit, without subclassing `UIImageView`. Check out the __[demo](#demo-app)__. If you're looking for the Japanese prefecture, click [here](https://goo.gl/maps/CCeAc).
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).

#### Why?

Expand All @@ -17,7 +17,7 @@ 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):

<img src="https://raw.githubusercontent.com/kaishin/gifu/master/figure.gif" width="300" />
<img src="https://db.tt/ZLfx23hg" width="300" />

#### Usage

Expand All @@ -42,9 +42,7 @@ The `isAnimating()` method returns the current animation state of the view.

#### Demo App

For an example, check out the demo app [here](https://github.com/kaishin/gifu/tree/demo) (requires Xcode 6).

<img src="https://raw.githubusercontent.com/kaishin/gifu/demo/demo.gif" width="300" />
<img src="https://db.tt/ZoUNLHGp" width="300" />

#### Compatibility

Expand Down
26 changes: 26 additions & 0 deletions demo/Images.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"images" : [
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "New [email protected]",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "New [email protected]",
"scale" : "2x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "New [email protected]",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions demo/Images.xcassets/LaunchImage.launchimage/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"orientation" : "portrait",
"idiom" : "iphone",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"subtype" : "retina4",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
40 changes: 40 additions & 0 deletions demo/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>co.kaishin.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
103 changes: 103 additions & 0 deletions demo/Main.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6206.9" systemVersion="13E28" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="vXZ-lx-hvc">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7026.1"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
</dependencies>
<scenes>
<!--Gifu-->
<scene sceneID="ufC-wZ-h7g">
<objects>
<viewController title="Gifu" id="vXZ-lx-hvc" customClass="ViewController" customModule="gifu_demo" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="jyV-Pf-zRb"/>
<viewControllerLayoutGuide type="bottom" id="2fi-mo-0CV"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="kh9-bI-dsS">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="FSz-xF-Xds">
<rect key="frame" x="75" y="150" width="450" height="300"/>
<color key="backgroundColor" red="0.7725490196" green="0.1764705882" blue="0.1843137255" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="height" constant="300" id="oev-E3-JrW"/>
<constraint firstAttribute="width" secondItem="FSz-xF-Xds" secondAttribute="height" multiplier="1.5:1" id="vUc-PW-K4t"/>
</constraints>
</imageView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="bFY-3J-OXr" customClass="FlatButton" customModule="gifu_demo" customModuleProvider="target">
<rect key="frame" x="275" y="509" width="50" height="50"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="Lmc-xA-WNU"/>
<constraint firstAttribute="height" constant="50" id="d3c-zA-X4Y"/>
<constraint firstAttribute="width" constant="50" id="eYX-lm-C2V"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<color key="tintColor" red="0.99444444444444446" green="1" blue="0.98888888888888893" alpha="1" colorSpace="calibratedRGB"/>
<state key="normal" title="❙❙"/>
<variation key="default">
<mask key="constraints">
<exclude reference="d3c-zA-X4Y"/>
</mask>
</variation>
<connections>
<action selector="toggleAnimation:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="PvH-3E-LbB"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Gifu" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="c8Y-41-BaC">
<rect key="frame" x="283" y="45" width="42" height="20.5"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="42" id="1Mg-oH-beY"/>
</constraints>
<fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Not the Japanese prefecture." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="wsv-cU-WO5">
<rect key="frame" x="217" y="69" width="175" height="13.5"/>
<constraints>
<constraint firstAttribute="width" constant="175" id="qtB-pf-agE"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="11"/>
<color key="textColor" red="1" green="1" blue="1" alpha="0.5" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" red="0.2304944545" green="0.24875254929999999" blue="0.2778563201" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="centerY" secondItem="bFY-3J-OXr" secondAttribute="centerY" id="09i-ag-RTM"/>
<constraint firstItem="bFY-3J-OXr" firstAttribute="top" secondItem="FSz-xF-Xds" secondAttribute="bottom" constant="-73" id="1KN-hB-V2y"/>
<constraint firstAttribute="centerX" secondItem="bFY-3J-OXr" secondAttribute="centerX" id="CNh-OD-Msi"/>
<constraint firstItem="c8Y-41-BaC" firstAttribute="top" secondItem="jyV-Pf-zRb" secondAttribute="bottom" constant="25" id="JHy-q1-JuJ"/>
<constraint firstAttribute="centerX" secondItem="c8Y-41-BaC" secondAttribute="centerX" constant="-4" id="Kc0-P5-KMZ"/>
<constraint firstItem="wsv-cU-WO5" firstAttribute="leading" secondItem="c8Y-41-BaC" secondAttribute="trailing" constant="-108" id="WMw-79-FUC"/>
<constraint firstItem="wsv-cU-WO5" firstAttribute="top" secondItem="c8Y-41-BaC" secondAttribute="bottom" constant="3.5" id="cLO-Rh-lrl"/>
<constraint firstItem="bFY-3J-OXr" firstAttribute="centerY" secondItem="FSz-xF-Xds" secondAttribute="centerY" constant="102" id="eTb-IQ-R1d"/>
<constraint firstAttribute="centerY" secondItem="FSz-xF-Xds" secondAttribute="centerY" id="lUc-8z-Gjn"/>
<constraint firstAttribute="centerX" secondItem="FSz-xF-Xds" secondAttribute="centerX" id="oih-yH-vRh"/>
<constraint firstItem="2fi-mo-0CV" firstAttribute="top" secondItem="bFY-3J-OXr" secondAttribute="bottom" constant="41" id="w4g-Xu-ht2"/>
<constraint firstItem="bFY-3J-OXr" firstAttribute="top" secondItem="FSz-xF-Xds" secondAttribute="bottom" constant="-73" id="wKy-oP-72d"/>
<constraint firstAttribute="centerX" secondItem="wsv-cU-WO5" secondAttribute="centerX" constant="-4.5" id="yLb-zR-gfU"/>
</constraints>
<variation key="default">
<mask key="constraints">
<exclude reference="09i-ag-RTM"/>
<exclude reference="1KN-hB-V2y"/>
<exclude reference="eTb-IQ-R1d"/>
<exclude reference="wKy-oP-72d"/>
</mask>
</variation>
</view>
<simulatedStatusBarMetrics key="simulatedStatusBarMetrics" statusBarStyle="lightContent"/>
<nil key="simulatedTopBarMetrics"/>
<nil key="simulatedBottomBarMetrics"/>
<connections>
<outlet property="button" destination="bFY-3J-OXr" id="MYJ-Xm-nTf"/>
<outlet property="imageView" destination="FSz-xF-Xds" id="gtV-MK-Fwd"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="x5A-6p-PRh" sceneMemberID="firstResponder"/>
</objects>
</scene>
</scenes>
</document>
12 changes: 12 additions & 0 deletions demo/classes/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
return true
}
}

48 changes: 48 additions & 0 deletions demo/classes/FlatButton.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import UIKit

class FlatButton: UIButton {

let horizontalPadding: CGFloat = 14.0

var buttonColor: UIColor?

override init(frame: CGRect) {
super.init(frame: frame)
customizeAppearance()
}

required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
customizeAppearance()
}

override func drawRect(rect: CGRect) {
layer.borderColor = tintColor.CGColor
setTitleColor(tintColor, forState: UIControlState.Normal)
setTitleColor(UIColor.whiteColor(), forState: UIControlState.Selected)
}

func customizeAppearance() {
let containsEdgeInsets = !UIEdgeInsetsEqualToEdgeInsets(contentEdgeInsets, UIEdgeInsetsZero)
contentEdgeInsets = containsEdgeInsets ? contentEdgeInsets : UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
layer.borderWidth = 2.0
layer.borderColor = tintColor.CGColor
layer.cornerRadius = frame.size.height / 2.0
layer.masksToBounds = true
}

override var tintColor: UIColor! {
get {
if let color = buttonColor {
return color
} else {
return super.tintColor
}
}

set {
super.tintColor = newValue
buttonColor = newValue
}
}
}
27 changes: 27 additions & 0 deletions demo/classes/ViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import UIKit

class ViewController: UIViewController {

@IBOutlet weak var imageView: UIImageView!
@IBOutlet weak var button: FlatButton!

override func viewDidLoad() {
super.viewDidLoad()
imageView.setAnimatableImage(named: "mugen.gif")
imageView.startAnimating()
UIApplication.sharedApplication().setStatusBarStyle(.LightContent, animated: false)
}

@IBAction func toggleAnimation(button: UIButton) {
if imageView.isAnimating {
imageView.stopAnimating()
button.layer.backgroundColor = UIColor.whiteColor().CGColor
button.setTitleColor(UIColor.blackColor(), forState: .Normal)
} else {
imageView.startAnimating()
button.layer.backgroundColor = UIColor.clearColor().CGColor
button.setTitleColor(UIColor.whiteColor(), forState: .Normal)
}
}
}

Binary file added demo/mugen.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed figure.gif
Binary file not shown.
Loading

0 comments on commit 0e48455

Please sign in to comment.