Skip to content

Commit 5651289

Browse files
committed
Add Rotation animation
1 parent 3c9ccc5 commit 5651289

File tree

7 files changed

+118
-4
lines changed

7 files changed

+118
-4
lines changed

iOSAnimationSample.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
/* Begin PBXBuildFile section */
1010
AE337B3C1AF260C0005F4AE1 /* ScaleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE337B3B1AF260C0005F4AE1 /* ScaleViewController.swift */; };
1111
AE337B3E1AF26525005F4AE1 /* ColorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE337B3D1AF26525005F4AE1 /* ColorViewController.swift */; };
12+
AE337B401AF2E1F0005F4AE1 /* RotationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE337B3F1AF2E1F0005F4AE1 /* RotationViewController.swift */; };
1213
AE8A3A591AF2598200815F4B /* OpacityViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE8A3A581AF2598200815F4B /* OpacityViewController.swift */; };
1314
AECE40101AEF7274005A5415 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = AECE400F1AEF7274005A5415 /* AppDelegate.swift */; };
1415
AECE40121AEF7274005A5415 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AECE40111AEF7274005A5415 /* ViewController.swift */; };
@@ -32,6 +33,7 @@
3233
/* Begin PBXFileReference section */
3334
AE337B3B1AF260C0005F4AE1 /* ScaleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScaleViewController.swift; sourceTree = "<group>"; };
3435
AE337B3D1AF26525005F4AE1 /* ColorViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ColorViewController.swift; sourceTree = "<group>"; };
36+
AE337B3F1AF2E1F0005F4AE1 /* RotationViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RotationViewController.swift; sourceTree = "<group>"; };
3537
AE8A3A581AF2598200815F4B /* OpacityViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OpacityViewController.swift; sourceTree = "<group>"; };
3638
AECE400A1AEF7274005A5415 /* iOSAnimationSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iOSAnimationSample.app; sourceTree = BUILT_PRODUCTS_DIR; };
3739
AECE400E1AEF7274005A5415 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
@@ -92,6 +94,7 @@
9294
AE8A3A581AF2598200815F4B /* OpacityViewController.swift */,
9395
AE337B3B1AF260C0005F4AE1 /* ScaleViewController.swift */,
9496
AE337B3D1AF26525005F4AE1 /* ColorViewController.swift */,
97+
AE337B3F1AF2E1F0005F4AE1 /* RotationViewController.swift */,
9598
AECE40161AEF7274005A5415 /* Images.xcassets */,
9699
AECE40181AEF7274005A5415 /* LaunchScreen.xib */,
97100
AECE400D1AEF7274005A5415 /* Supporting Files */,
@@ -228,6 +231,7 @@
228231
AE337B3C1AF260C0005F4AE1 /* ScaleViewController.swift in Sources */,
229232
AECE40121AEF7274005A5415 /* ViewController.swift in Sources */,
230233
AE8A3A591AF2598200815F4B /* OpacityViewController.swift in Sources */,
234+
AE337B401AF2E1F0005F4AE1 /* RotationViewController.swift in Sources */,
231235
AE337B3E1AF26525005F4AE1 /* ColorViewController.swift in Sources */,
232236
AECE40101AEF7274005A5415 /* AppDelegate.swift in Sources */,
233237
);

iOSAnimationSample/Base.lproj/Main.storyboard

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<tableViewSection id="5Zl-t8-hX6">
1717
<cells>
1818
<tableViewCell contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" textLabel="LkM-fX-yuq" style="IBUITableViewCellStyleDefault" id="f2m-kP-WQN">
19-
<rect key="frame" x="0.0" y="64" width="320" height="44"/>
19+
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
2020
<autoresizingMask key="autoresizingMask"/>
2121
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="f2m-kP-WQN" id="0Fm-gu-epR">
2222
<rect key="frame" x="0.0" y="0.0" width="287" height="43"/>
@@ -35,7 +35,7 @@
3535
</connections>
3636
</tableViewCell>
3737
<tableViewCell contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" textLabel="Dej-jB-xjg" style="IBUITableViewCellStyleDefault" id="8pR-US-B47">
38-
<rect key="frame" x="0.0" y="108" width="320" height="44"/>
38+
<rect key="frame" x="0.0" y="44" width="320" height="44"/>
3939
<autoresizingMask key="autoresizingMask"/>
4040
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="8pR-US-B47" id="Of1-Db-ADX">
4141
<rect key="frame" x="0.0" y="0.0" width="287" height="43"/>
@@ -54,7 +54,7 @@
5454
</connections>
5555
</tableViewCell>
5656
<tableViewCell contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" textLabel="cCE-B5-QCt" style="IBUITableViewCellStyleDefault" id="6ul-lI-pLs">
57-
<rect key="frame" x="0.0" y="152" width="320" height="44"/>
57+
<rect key="frame" x="0.0" y="88" width="320" height="44"/>
5858
<autoresizingMask key="autoresizingMask"/>
5959
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="6ul-lI-pLs" id="Acl-X3-y9C">
6060
<rect key="frame" x="0.0" y="0.0" width="287" height="43"/>
@@ -73,7 +73,7 @@
7373
</connections>
7474
</tableViewCell>
7575
<tableViewCell contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" textLabel="9v2-62-grt" style="IBUITableViewCellStyleDefault" id="KSN-gh-s6L">
76-
<rect key="frame" x="0.0" y="196" width="320" height="44"/>
76+
<rect key="frame" x="0.0" y="132" width="320" height="44"/>
7777
<autoresizingMask key="autoresizingMask"/>
7878
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KSN-gh-s6L" id="ek7-de-c2O">
7979
<rect key="frame" x="0.0" y="0.0" width="287" height="43"/>
@@ -91,6 +91,25 @@
9191
<segue destination="UBL-bn-Me0" kind="push" id="EVz-2G-zhx"/>
9292
</connections>
9393
</tableViewCell>
94+
<tableViewCell contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" textLabel="Nh1-4o-xbN" style="IBUITableViewCellStyleDefault" id="wj3-L7-mdr">
95+
<rect key="frame" x="0.0" y="176" width="320" height="44"/>
96+
<autoresizingMask key="autoresizingMask"/>
97+
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="wj3-L7-mdr" id="4UJ-qv-zmo">
98+
<rect key="frame" x="0.0" y="0.0" width="287" height="43"/>
99+
<autoresizingMask key="autoresizingMask"/>
100+
<subviews>
101+
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Ratation" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Nh1-4o-xbN">
102+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
103+
<fontDescription key="fontDescription" type="system" pointSize="16"/>
104+
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
105+
<nil key="highlightedColor"/>
106+
</label>
107+
</subviews>
108+
</tableViewCellContentView>
109+
<connections>
110+
<segue destination="vEa-GA-RrH" kind="push" id="S4E-Nm-Sdo"/>
111+
</connections>
112+
</tableViewCell>
94113
</cells>
95114
</tableViewSection>
96115
</sections>
@@ -254,7 +273,34 @@
254273
</objects>
255274
<point key="canvasLocation" x="1052" y="2269"/>
256275
</scene>
276+
<!--Rotation View Controller-->
277+
<scene sceneID="wuK-yB-vkI">
278+
<objects>
279+
<viewController id="vEa-GA-RrH" customClass="RotationViewController" customModule="iOSAnimationSample" customModuleProvider="target" sceneMemberID="viewController">
280+
<view key="view" contentMode="scaleToFill" id="ESq-Ly-PNT">
281+
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
282+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
283+
<subviews>
284+
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="wheel" id="zqO-6F-C4M">
285+
<rect key="frame" x="10" y="134" width="300" height="300"/>
286+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
287+
</imageView>
288+
</subviews>
289+
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
290+
</view>
291+
<navigationItem key="navigationItem" id="zNn-6a-BC3"/>
292+
<connections>
293+
<outlet property="wheel" destination="zqO-6F-C4M" id="0lg-ak-2i2"/>
294+
</connections>
295+
</viewController>
296+
<placeholder placeholderIdentifier="IBFirstResponder" id="3pV-yw-mTI" userLabel="First Responder" sceneMemberID="firstResponder"/>
297+
</objects>
298+
<point key="canvasLocation" x="1052" y="2919"/>
299+
</scene>
257300
</scenes>
301+
<resources>
302+
<image name="wheel" width="894" height="894"/>
303+
</resources>
258304
<simulatedMetricsContainer key="defaultSimulatedMetrics">
259305
<simulatedStatusBarMetrics key="statusBar"/>
260306
<simulatedOrientationMetrics key="orientation"/>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"scale" : "1x",
6+
"filename" : "wheel.png"
7+
},
8+
{
9+
"idiom" : "universal",
10+
"scale" : "2x",
11+
"filename" : "wheel-1.png"
12+
},
13+
{
14+
"idiom" : "universal",
15+
"scale" : "3x",
16+
"filename" : "wheel-2.png"
17+
}
18+
],
19+
"info" : {
20+
"version" : 1,
21+
"author" : "xcode"
22+
}
23+
}
Loading
Loading
Loading
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//
2+
// RotationViewController.swift
3+
// iOSAnimationSample
4+
//
5+
// Created by Jake Lin on 5/1/15.
6+
// Copyright (c) 2015 JakeLin. All rights reserved.
7+
//
8+
9+
import UIKit
10+
11+
class RotationViewController: UIViewController {
12+
13+
@IBOutlet weak var wheel: UIImageView!
14+
override func viewDidLoad() {
15+
super.viewDidLoad()
16+
17+
// Do any additional setup after loading the view.
18+
}
19+
20+
override func didReceiveMemoryWarning() {
21+
super.didReceiveMemoryWarning()
22+
// Dispose of any resources that can be recreated.
23+
}
24+
25+
override func viewDidAppear(animated: Bool) {
26+
UIView.animateWithDuration(1, animations: {
27+
self.wheel.transform = CGAffineTransformMakeRotation(CGFloat(M_PI))
28+
})
29+
}
30+
31+
/*
32+
// MARK: - Navigation
33+
34+
// In a storyboard-based application, you will often want to do a little preparation before navigation
35+
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
36+
// Get the new view controller using segue.destinationViewController.
37+
// Pass the selected object to the new view controller.
38+
}
39+
*/
40+
41+
}

0 commit comments

Comments
 (0)