Skip to content

Commit 34a976a

Browse files
committed
Add Easing Animation
1 parent 88af92d commit 34a976a

File tree

4 files changed

+124
-0
lines changed

4 files changed

+124
-0
lines changed

iOSAnimationSample.xcodeproj/project.pbxproj

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
/* Begin PBXBuildFile section */
1010
AE17FD3E1AF820ED0086BC39 /* RepeatViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE17FD3D1AF820ED0086BC39 /* RepeatViewController.swift */; };
11+
AE17FD401AF824990086BC39 /* EasingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE17FD3F1AF824990086BC39 /* EasingViewController.swift */; };
1112
AE337B3C1AF260C0005F4AE1 /* ScaleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE337B3B1AF260C0005F4AE1 /* ScaleViewController.swift */; };
1213
AE337B3E1AF26525005F4AE1 /* ColorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE337B3D1AF26525005F4AE1 /* ColorViewController.swift */; };
1314
AE337B401AF2E1F0005F4AE1 /* RotationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE337B3F1AF2E1F0005F4AE1 /* RotationViewController.swift */; };
@@ -33,6 +34,7 @@
3334

3435
/* Begin PBXFileReference section */
3536
AE17FD3D1AF820ED0086BC39 /* RepeatViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RepeatViewController.swift; sourceTree = "<group>"; };
37+
AE17FD3F1AF824990086BC39 /* EasingViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EasingViewController.swift; sourceTree = "<group>"; };
3638
AE337B3B1AF260C0005F4AE1 /* ScaleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScaleViewController.swift; sourceTree = "<group>"; };
3739
AE337B3D1AF26525005F4AE1 /* ColorViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ColorViewController.swift; sourceTree = "<group>"; };
3840
AE337B3F1AF2E1F0005F4AE1 /* RotationViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RotationViewController.swift; sourceTree = "<group>"; };
@@ -97,6 +99,7 @@
9799
AE337B3D1AF26525005F4AE1 /* ColorViewController.swift */,
98100
AE337B3F1AF2E1F0005F4AE1 /* RotationViewController.swift */,
99101
AE17FD3D1AF820ED0086BC39 /* RepeatViewController.swift */,
102+
AE17FD3F1AF824990086BC39 /* EasingViewController.swift */,
100103
AECE40131AEF7274005A5415 /* Main.storyboard */,
101104
AECE40161AEF7274005A5415 /* Images.xcassets */,
102105
AECE40181AEF7274005A5415 /* LaunchScreen.xib */,
@@ -232,6 +235,7 @@
232235
files = (
233236
AECE40301AF03D91005A5415 /* PositionViewController.swift in Sources */,
234237
AE337B3C1AF260C0005F4AE1 /* ScaleViewController.swift in Sources */,
238+
AE17FD401AF824990086BC39 /* EasingViewController.swift in Sources */,
235239
AECE40121AEF7274005A5415 /* ViewController.swift in Sources */,
236240
AE8A3A591AF2598200815F4B /* OpacityViewController.swift in Sources */,
237241
AE337B401AF2E1F0005F4AE1 /* RotationViewController.swift in Sources */,

iOSAnimationSample/Base.lproj/Main.storyboard

+62
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,25 @@
129129
<segue destination="hKq-Qm-Wo1" kind="push" id="gol-c1-csi"/>
130130
</connections>
131131
</tableViewCell>
132+
<tableViewCell contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" textLabel="FC8-Nz-Owv" style="IBUITableViewCellStyleDefault" id="TBd-xr-vvB">
133+
<rect key="frame" x="0.0" y="328" width="320" height="44"/>
134+
<autoresizingMask key="autoresizingMask"/>
135+
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="TBd-xr-vvB" id="Yil-kF-bS6">
136+
<rect key="frame" x="0.0" y="0.0" width="287" height="43"/>
137+
<autoresizingMask key="autoresizingMask"/>
138+
<subviews>
139+
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Easing" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="FC8-Nz-Owv">
140+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
141+
<fontDescription key="fontDescription" type="system" pointSize="16"/>
142+
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
143+
<nil key="highlightedColor"/>
144+
</label>
145+
</subviews>
146+
</tableViewCellContentView>
147+
<connections>
148+
<segue destination="kNR-0P-iRv" kind="push" id="dBp-KC-URn"/>
149+
</connections>
150+
</tableViewCell>
132151
</cells>
133152
</tableViewSection>
134153
</sections>
@@ -353,6 +372,49 @@
353372
</objects>
354373
<point key="canvasLocation" x="1052" y="3568"/>
355374
</scene>
375+
<!--Easing View Controller-->
376+
<scene sceneID="Jis-Ay-CNC">
377+
<objects>
378+
<viewController id="kNR-0P-iRv" customClass="EasingViewController" customModule="iOSAnimationSample" customModuleProvider="target" sceneMemberID="viewController">
379+
<view key="view" contentMode="scaleToFill" id="Ujf-ov-K11">
380+
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
381+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
382+
<subviews>
383+
<view contentMode="scaleToFill" id="vLH-GC-j0i">
384+
<rect key="frame" x="16" y="101" width="60" height="60"/>
385+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
386+
<color key="backgroundColor" red="0.22802925860000001" green="0.66314832059999995" blue="0.70600328950000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
387+
</view>
388+
<view contentMode="scaleToFill" id="cdR-k7-Cvz">
389+
<rect key="frame" x="16" y="287" width="60" height="60"/>
390+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
391+
<color key="backgroundColor" red="0.40933579640000001" green="0.80104922519999999" blue="0.036929481930000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
392+
</view>
393+
<view contentMode="scaleToFill" id="26l-js-32n">
394+
<rect key="frame" x="16" y="380" width="60" height="60"/>
395+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
396+
<color key="backgroundColor" red="0.96338383838383834" green="0.96308892366865062" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
397+
</view>
398+
<view contentMode="scaleToFill" id="brU-du-GnR">
399+
<rect key="frame" x="16" y="195" width="60" height="60"/>
400+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
401+
<color key="backgroundColor" red="0.96142769610000001" green="0.19560617420000001" blue="0.27446546059999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
402+
</view>
403+
</subviews>
404+
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
405+
</view>
406+
<navigationItem key="navigationItem" id="9X0-T2-lk7"/>
407+
<connections>
408+
<outlet property="blueSquare" destination="vLH-GC-j0i" id="Rb1-U3-BIe"/>
409+
<outlet property="greenSquare" destination="cdR-k7-Cvz" id="lom-vd-mGN"/>
410+
<outlet property="redSquare" destination="brU-du-GnR" id="1pO-oP-PoH"/>
411+
<outlet property="yellowSqaure" destination="26l-js-32n" id="vxa-Q4-s0C"/>
412+
</connections>
413+
</viewController>
414+
<placeholder placeholderIdentifier="IBFirstResponder" id="dXR-bu-zlV" userLabel="First Responder" sceneMemberID="firstResponder"/>
415+
</objects>
416+
<point key="canvasLocation" x="1052" y="4200"/>
417+
</scene>
356418
</scenes>
357419
<resources>
358420
<image name="wheel" width="894" height="894"/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
//
2+
// EasingViewController.swift
3+
// iOSAnimationSample
4+
//
5+
// Created by Jake Lin on 5/5/15.
6+
// Copyright (c) 2015 JakeLin. All rights reserved.
7+
//
8+
9+
import UIKit
10+
11+
class EasingViewController: UIViewController {
12+
13+
@IBOutlet weak var blueSquare: UIView!
14+
@IBOutlet weak var redSquare: UIView!
15+
@IBOutlet weak var greenSquare: UIView!
16+
@IBOutlet weak var yellowSqaure: UIView!
17+
18+
override func viewDidLoad() {
19+
super.viewDidLoad()
20+
21+
// Do any additional setup after loading the view.
22+
}
23+
24+
override func didReceiveMemoryWarning() {
25+
super.didReceiveMemoryWarning()
26+
// Dispose of any resources that can be recreated.
27+
}
28+
29+
override func viewDidAppear(animated: Bool) {
30+
UIView.animateWithDuration(1, animations: {
31+
self.blueSquare.center.x = self.view.bounds.width - self.blueSquare.center.x
32+
})
33+
34+
UIView.animateWithDuration(1, delay: 0, options: .CurveEaseIn, animations: {
35+
self.redSquare.center.x = self.view.bounds.width - self.redSquare.center.x
36+
}, completion: nil)
37+
38+
UIView.animateWithDuration(1, delay: 0, options: .CurveEaseOut, animations: {
39+
self.greenSquare.center.x = self.view.bounds.width - self.greenSquare.center.x
40+
}, completion: nil)
41+
42+
UIView.animateWithDuration(1, delay: 0, options: .CurveEaseInOut, animations: {
43+
self.yellowSqaure.center.x = self.view.bounds.width - self.yellowSqaure.center.x
44+
}, completion: nil)
45+
}
46+
47+
/*
48+
// MARK: - Navigation
49+
50+
// In a storyboard-based application, you will often want to do a little preparation before navigation
51+
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
52+
// Get the new view controller using segue.destinationViewController.
53+
// Pass the selected object to the new view controller.
54+
}
55+
*/
56+
57+
}

iOSAnimationSample/RepeatViewController.swift

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class RepeatViewController: UIViewController {
2626
super.didReceiveMemoryWarning()
2727
// Dispose of any resources that can be recreated.
2828
}
29+
2930
override func viewDidAppear(animated: Bool) {
3031
UIView.animateWithDuration(1, animations: {
3132
self.blueSquare.center.x = self.view.bounds.width - self.blueSquare.center.x

0 commit comments

Comments
 (0)