Skip to content

Commit 251f3e4

Browse files
committed
Add a green box animating in both both ways(x and y axises)
1 parent a6ac9af commit 251f3e4

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

iOSAnimationSample/Base.lproj/Main.storyboard

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,18 @@
6666
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
6767
<color key="backgroundColor" red="0.96142769610000001" green="0.19560617421842103" blue="0.2744654605526316" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
6868
</view>
69+
<view contentMode="scaleToFill" id="uDJ-7O-6n6">
70+
<rect key="frame" x="244" y="86" width="60" height="60"/>
71+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
72+
<color key="backgroundColor" red="0.40933579642894741" green="0.80104922520526145" blue="0.036929481934210528" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
73+
</view>
6974
</subviews>
7075
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
7176
</view>
7277
<navigationItem key="navigationItem" id="cGh-aI-gZo"/>
7378
<connections>
7479
<outlet property="blueSquare" destination="azk-Fu-KuD" id="GHY-Yf-xjc"/>
80+
<outlet property="greenSquare" destination="uDJ-7O-6n6" id="9hC-l4-Vhd"/>
7581
<outlet property="redSquare" destination="qDn-u2-IJk" id="VpL-zc-ufr"/>
7682
</connections>
7783
</viewController>

iOSAnimationSample/PositionViewController.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import UIKit
1111
class PositionViewController: UIViewController {
1212
@IBOutlet weak var blueSquare: UIView!
1313
@IBOutlet weak var redSquare: UIView!
14+
@IBOutlet weak var greenSquare: UIView!
1415

1516
override func viewDidLoad() {
1617
super.viewDidLoad()
@@ -34,6 +35,9 @@ class PositionViewController: UIViewController {
3435
UIView.animateWithDuration(1, animations: {
3536
self.blueSquare.center.x = self.view.bounds.width - self.blueSquare.center.x
3637
self.redSquare.center.y = self.view.bounds.height - self.redSquare.center.y
38+
39+
self.greenSquare.center.x = self.view.bounds.width - self.greenSquare.center.x
40+
self.greenSquare.center.y = self.view.bounds.height - self.greenSquare.center.y
3741
// <_UIViewAdditiveAnimationAction: 0x7fe17b70df30>
3842
// println(self.view.actionForLayer(self.view.layer, forKey: "position"))
3943
})

0 commit comments

Comments
 (0)