Skip to content

Commit 3fc04b4

Browse files
committed
Add UIView Opacity animation
1 parent f855bb6 commit 3fc04b4

File tree

4 files changed

+95
-4
lines changed

4 files changed

+95
-4
lines changed

iOSAnimationSample.xcodeproj/project.pbxproj

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

99
/* Begin PBXBuildFile section */
10+
AE8A3A591AF2598200815F4B /* OpacityViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE8A3A581AF2598200815F4B /* OpacityViewController.swift */; };
1011
AECE40101AEF7274005A5415 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = AECE400F1AEF7274005A5415 /* AppDelegate.swift */; };
1112
AECE40121AEF7274005A5415 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AECE40111AEF7274005A5415 /* ViewController.swift */; };
1213
AECE40151AEF7274005A5415 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AECE40131AEF7274005A5415 /* Main.storyboard */; };
@@ -27,6 +28,7 @@
2728
/* End PBXContainerItemProxy section */
2829

2930
/* Begin PBXFileReference section */
31+
AE8A3A581AF2598200815F4B /* OpacityViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OpacityViewController.swift; sourceTree = "<group>"; };
3032
AECE400A1AEF7274005A5415 /* iOSAnimationSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iOSAnimationSample.app; sourceTree = BUILT_PRODUCTS_DIR; };
3133
AECE400E1AEF7274005A5415 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
3234
AECE400F1AEF7274005A5415 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
@@ -86,6 +88,7 @@
8688
AECE40161AEF7274005A5415 /* Images.xcassets */,
8789
AECE40181AEF7274005A5415 /* LaunchScreen.xib */,
8890
AECE400D1AEF7274005A5415 /* Supporting Files */,
91+
AE8A3A581AF2598200815F4B /* OpacityViewController.swift */,
8992
);
9093
path = iOSAnimationSample;
9194
sourceTree = "<group>";
@@ -217,6 +220,7 @@
217220
files = (
218221
AECE40301AF03D91005A5415 /* PositionViewController.swift in Sources */,
219222
AECE40121AEF7274005A5415 /* ViewController.swift in Sources */,
223+
AE8A3A591AF2598200815F4B /* OpacityViewController.swift in Sources */,
220224
AECE40101AEF7274005A5415 /* AppDelegate.swift in Sources */,
221225
);
222226
runOnlyForDeploymentPostprocessing = 0;
@@ -409,6 +413,7 @@
409413
AECE402B1AEF7274005A5415 /* Release */,
410414
);
411415
defaultConfigurationIsVisible = 0;
416+
defaultConfigurationName = Release;
412417
};
413418
AECE402C1AEF7274005A5415 /* Build configuration list for PBXNativeTarget "iOSAnimationSampleTests" */ = {
414419
isa = XCConfigurationList;
@@ -417,6 +422,7 @@
417422
AECE402E1AEF7274005A5415 /* Release */,
418423
);
419424
defaultConfigurationIsVisible = 0;
425+
defaultConfigurationName = Release;
420426
};
421427
/* End XCConfigurationList section */
422428
};

iOSAnimationSample/Base.lproj/Main.storyboard

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,25 @@
3434
<segue destination="MKq-Vq-bKV" kind="push" id="r77-pb-zKw"/>
3535
</connections>
3636
</tableViewCell>
37+
<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"/>
39+
<autoresizingMask key="autoresizingMask"/>
40+
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="8pR-US-B47" id="Of1-Db-ADX">
41+
<rect key="frame" x="0.0" y="0.0" width="287" height="43"/>
42+
<autoresizingMask key="autoresizingMask"/>
43+
<subviews>
44+
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Opacity" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Dej-jB-xjg">
45+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
46+
<fontDescription key="fontDescription" type="system" pointSize="16"/>
47+
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
48+
<nil key="highlightedColor"/>
49+
</label>
50+
</subviews>
51+
</tableViewCellContentView>
52+
<connections>
53+
<segue destination="uqT-8N-YiP" kind="push" id="BzM-NV-epb"/>
54+
</connections>
55+
</tableViewCell>
3756
</cells>
3857
</tableViewSection>
3958
</sections>
@@ -48,6 +67,36 @@
4867
</objects>
4968
<point key="canvasLocation" x="641" y="325"/>
5069
</scene>
70+
<!--Opacity View Controller-->
71+
<scene sceneID="CYE-UH-yeA">
72+
<objects>
73+
<viewController id="uqT-8N-YiP" customClass="OpacityViewController" customModule="iOSAnimationSample" customModuleProvider="target" sceneMemberID="viewController">
74+
<view key="view" contentMode="scaleToFill" id="wod-nk-Szf">
75+
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
76+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
77+
<subviews>
78+
<view contentMode="scaleToFill" id="G7f-fN-dyV">
79+
<rect key="frame" x="100" y="122" width="120" height="120"/>
80+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
81+
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
82+
</view>
83+
<view contentMode="scaleToFill" id="Y6G-mp-cqc">
84+
<rect key="frame" x="100" y="100" width="120" height="120"/>
85+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
86+
<color key="backgroundColor" red="0.22802925860000001" green="0.66314832059999995" blue="0.70600328950000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
87+
</view>
88+
</subviews>
89+
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
90+
</view>
91+
<navigationItem key="navigationItem" id="ZwJ-3g-khd"/>
92+
<connections>
93+
<outlet property="blueSquare" destination="Y6G-mp-cqc" id="cuf-fI-LeC"/>
94+
</connections>
95+
</viewController>
96+
<placeholder placeholderIdentifier="IBFirstResponder" id="AP4-Dv-vzH" userLabel="First Responder" sceneMemberID="firstResponder"/>
97+
</objects>
98+
<point key="canvasLocation" x="1052" y="961"/>
99+
</scene>
51100
<!--Position View Controller-->
52101
<scene sceneID="Oe7-Wf-h91">
53102
<objects>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//
2+
// OpacityViewController.swift
3+
// iOSAnimationSample
4+
//
5+
// Created by Jake Lin on 4/30/15.
6+
// Copyright (c) 2015 JakeLin. All rights reserved.
7+
//
8+
9+
import UIKit
10+
11+
class OpacityViewController: UIViewController {
12+
@IBOutlet weak var blueSquare: UIView!
13+
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.blueSquare.alpha = 0.2
28+
})
29+
}
30+
/*
31+
// MARK: - Navigation
32+
33+
// In a storyboard-based application, you will often want to do a little preparation before navigation
34+
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
35+
// Get the new view controller using segue.destinationViewController.
36+
// Pass the selected object to the new view controller.
37+
}
38+
*/
39+
40+
}

iOSAnimationSample/PositionViewController.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ class PositionViewController: UIViewController {
2424
// Dispose of any resources that can be recreated.
2525
}
2626

27-
override func viewWillAppear(animated: Bool) {
28-
29-
}
30-
3127
override func viewDidAppear(animated: Bool) {
3228
// <null>
3329
// println(self.view.actionForLayer(self.view.layer, forKey: "position"))

0 commit comments

Comments
 (0)