Skip to content

Commit 88af92d

Browse files
committed
UIView Repeat Animation
1 parent d4c24f0 commit 88af92d

File tree

3 files changed

+119
-6
lines changed

3 files changed

+119
-6
lines changed

iOSAnimationSample.xcodeproj/project.pbxproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
AE17FD3E1AF820ED0086BC39 /* RepeatViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE17FD3D1AF820ED0086BC39 /* RepeatViewController.swift */; };
1011
AE337B3C1AF260C0005F4AE1 /* ScaleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE337B3B1AF260C0005F4AE1 /* ScaleViewController.swift */; };
1112
AE337B3E1AF26525005F4AE1 /* ColorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE337B3D1AF26525005F4AE1 /* ColorViewController.swift */; };
1213
AE337B401AF2E1F0005F4AE1 /* RotationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE337B3F1AF2E1F0005F4AE1 /* RotationViewController.swift */; };
@@ -31,6 +32,7 @@
3132
/* End PBXContainerItemProxy section */
3233

3334
/* Begin PBXFileReference section */
35+
AE17FD3D1AF820ED0086BC39 /* RepeatViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RepeatViewController.swift; sourceTree = "<group>"; };
3436
AE337B3B1AF260C0005F4AE1 /* ScaleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScaleViewController.swift; sourceTree = "<group>"; };
3537
AE337B3D1AF26525005F4AE1 /* ColorViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ColorViewController.swift; sourceTree = "<group>"; };
3638
AE337B3F1AF2E1F0005F4AE1 /* RotationViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RotationViewController.swift; sourceTree = "<group>"; };
@@ -89,12 +91,13 @@
8991
children = (
9092
AECE400F1AEF7274005A5415 /* AppDelegate.swift */,
9193
AECE40111AEF7274005A5415 /* ViewController.swift */,
92-
AECE40131AEF7274005A5415 /* Main.storyboard */,
9394
AECE402F1AF03D91005A5415 /* PositionViewController.swift */,
9495
AE8A3A581AF2598200815F4B /* OpacityViewController.swift */,
9596
AE337B3B1AF260C0005F4AE1 /* ScaleViewController.swift */,
9697
AE337B3D1AF26525005F4AE1 /* ColorViewController.swift */,
9798
AE337B3F1AF2E1F0005F4AE1 /* RotationViewController.swift */,
99+
AE17FD3D1AF820ED0086BC39 /* RepeatViewController.swift */,
100+
AECE40131AEF7274005A5415 /* Main.storyboard */,
98101
AECE40161AEF7274005A5415 /* Images.xcassets */,
99102
AECE40181AEF7274005A5415 /* LaunchScreen.xib */,
100103
AECE400D1AEF7274005A5415 /* Supporting Files */,
@@ -232,6 +235,7 @@
232235
AECE40121AEF7274005A5415 /* ViewController.swift in Sources */,
233236
AE8A3A591AF2598200815F4B /* OpacityViewController.swift in Sources */,
234237
AE337B401AF2E1F0005F4AE1 /* RotationViewController.swift in Sources */,
238+
AE17FD3E1AF820ED0086BC39 /* RepeatViewController.swift in Sources */,
235239
AE337B3E1AF26525005F4AE1 /* ColorViewController.swift in Sources */,
236240
AECE40101AEF7274005A5415 /* AppDelegate.swift in Sources */,
237241
);

iOSAnimationSample/Base.lproj/Main.storyboard

Lines changed: 61 additions & 5 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="0.0" width="320" height="44"/>
19+
<rect key="frame" x="0.0" y="64" 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="44" width="320" height="44"/>
38+
<rect key="frame" x="0.0" y="108" 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="88" width="320" height="44"/>
57+
<rect key="frame" x="0.0" y="152" 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="132" width="320" height="44"/>
76+
<rect key="frame" x="0.0" y="196" 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"/>
@@ -92,7 +92,7 @@
9292
</connections>
9393
</tableViewCell>
9494
<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"/>
95+
<rect key="frame" x="0.0" y="240" width="320" height="44"/>
9696
<autoresizingMask key="autoresizingMask"/>
9797
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="wj3-L7-mdr" id="4UJ-qv-zmo">
9898
<rect key="frame" x="0.0" y="0.0" width="287" height="43"/>
@@ -110,6 +110,25 @@
110110
<segue destination="vEa-GA-RrH" kind="push" id="S4E-Nm-Sdo"/>
111111
</connections>
112112
</tableViewCell>
113+
<tableViewCell contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" textLabel="HRB-sb-p1R" style="IBUITableViewCellStyleDefault" id="qpZ-7w-muN">
114+
<rect key="frame" x="0.0" y="284" width="320" height="44"/>
115+
<autoresizingMask key="autoresizingMask"/>
116+
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="qpZ-7w-muN" id="c45-sd-1lu">
117+
<rect key="frame" x="0.0" y="0.0" width="287" height="43"/>
118+
<autoresizingMask key="autoresizingMask"/>
119+
<subviews>
120+
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Repeat" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="HRB-sb-p1R">
121+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
122+
<fontDescription key="fontDescription" type="system" pointSize="16"/>
123+
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
124+
<nil key="highlightedColor"/>
125+
</label>
126+
</subviews>
127+
</tableViewCellContentView>
128+
<connections>
129+
<segue destination="hKq-Qm-Wo1" kind="push" id="gol-c1-csi"/>
130+
</connections>
131+
</tableViewCell>
113132
</cells>
114133
</tableViewSection>
115134
</sections>
@@ -297,6 +316,43 @@
297316
</objects>
298317
<point key="canvasLocation" x="1052" y="2919"/>
299318
</scene>
319+
<!--Repeat View Controller-->
320+
<scene sceneID="67P-zJ-EHU">
321+
<objects>
322+
<viewController id="hKq-Qm-Wo1" customClass="RepeatViewController" customModule="iOSAnimationSample" customModuleProvider="target" sceneMemberID="viewController">
323+
<view key="view" contentMode="scaleToFill" id="Yld-Kf-uRy">
324+
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
325+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
326+
<subviews>
327+
<view contentMode="scaleToFill" id="HaY-PU-UHz">
328+
<rect key="frame" x="16" y="101" width="60" height="60"/>
329+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
330+
<color key="backgroundColor" red="0.22802925860000001" green="0.66314832059999995" blue="0.70600328950000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
331+
</view>
332+
<view contentMode="scaleToFill" id="2S5-57-KgB">
333+
<rect key="frame" x="16" y="195" width="60" height="60"/>
334+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
335+
<color key="backgroundColor" red="0.96142769610000001" green="0.19560617420000001" blue="0.27446546059999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
336+
</view>
337+
<view contentMode="scaleToFill" id="yZe-LH-Y3L">
338+
<rect key="frame" x="16" y="287" width="60" height="60"/>
339+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
340+
<color key="backgroundColor" red="0.40933579640000001" green="0.80104922519999999" blue="0.036929481930000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
341+
</view>
342+
</subviews>
343+
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
344+
</view>
345+
<navigationItem key="navigationItem" id="9Yw-zA-lT7"/>
346+
<connections>
347+
<outlet property="blueSquare" destination="HaY-PU-UHz" id="uja-Pq-BR3"/>
348+
<outlet property="greenSquare" destination="yZe-LH-Y3L" id="dgp-iG-byr"/>
349+
<outlet property="redSquare" destination="2S5-57-KgB" id="MqH-LZ-tZc"/>
350+
</connections>
351+
</viewController>
352+
<placeholder placeholderIdentifier="IBFirstResponder" id="nD4-zU-jtP" userLabel="First Responder" sceneMemberID="firstResponder"/>
353+
</objects>
354+
<point key="canvasLocation" x="1052" y="3568"/>
355+
</scene>
300356
</scenes>
301357
<resources>
302358
<image name="wheel" width="894" height="894"/>
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
//
2+
// RepeatViewController.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 RepeatViewController: UIViewController {
12+
13+
@IBOutlet weak var blueSquare: UIView!
14+
15+
@IBOutlet weak var redSquare: UIView!
16+
17+
@IBOutlet weak var greenSquare: UIView!
18+
19+
override func viewDidLoad() {
20+
super.viewDidLoad()
21+
22+
// Do any additional setup after loading the view.
23+
}
24+
25+
override func didReceiveMemoryWarning() {
26+
super.didReceiveMemoryWarning()
27+
// Dispose of any resources that can be recreated.
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: .Repeat, 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: .Repeat | .Autoreverse, animations: {
39+
self.greenSquare.center.x = self.view.bounds.width - self.greenSquare.center.x
40+
}, completion: nil)
41+
}
42+
43+
/*
44+
// MARK: - Navigation
45+
46+
// In a storyboard-based application, you will often want to do a little preparation before navigation
47+
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
48+
// Get the new view controller using segue.destinationViewController.
49+
// Pass the selected object to the new view controller.
50+
}
51+
*/
52+
53+
}

0 commit comments

Comments
 (0)