Skip to content

Commit 9a81790

Browse files
committed
User Interface 3D Transforms: Version 1.0, 2017-04-27
First version. This sample code demonstrates applying 3D effects to an arbitrary UIView. A few different views are chosen randomly to facilitate this example: an image view, map view, and a web view. A view hierarchy is displayed that is akin to the tab switching user experience in Safari on iOS and the 3D nature of this effect is implemented using CALayer's CATransform3D. Signed-off-by: Liu Lantao <[email protected]>
1 parent 9704241 commit 9a81790

File tree

18 files changed

+997
-0
lines changed

18 files changed

+997
-0
lines changed

UserInterface3DTransforms/LICENSE.txt

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
Sample code project: User Interface 3D Transforms
2+
Version: 1.0
3+
4+
IMPORTANT: This Apple software is supplied to you by Apple
5+
Inc. ("Apple") in consideration of your agreement to the following
6+
terms, and your use, installation, modification or redistribution of
7+
this Apple software constitutes acceptance of these terms. If you do
8+
not agree with these terms, please do not use, install, modify or
9+
redistribute this Apple software.
10+
11+
In consideration of your agreement to abide by the following terms, and
12+
subject to these terms, Apple grants you a personal, non-exclusive
13+
license, under Apple's copyrights in this original Apple software (the
14+
"Apple Software"), to use, reproduce, modify and redistribute the Apple
15+
Software, with or without modifications, in source and/or binary forms;
16+
provided that if you redistribute the Apple Software in its entirety and
17+
without modifications, you must retain this notice and the following
18+
text and disclaimers in all such redistributions of the Apple Software.
19+
Neither the name, trademarks, service marks or logos of Apple Inc. may
20+
be used to endorse or promote products derived from the Apple Software
21+
without specific prior written permission from Apple. Except as
22+
expressly stated in this notice, no other rights or licenses, express or
23+
implied, are granted by Apple herein, including but not limited to any
24+
patent rights that may be infringed by your derivative works or by other
25+
works in which the Apple Software may be incorporated.
26+
27+
The Apple Software is provided by Apple on an "AS IS" basis. APPLE
28+
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
29+
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
30+
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
31+
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
32+
33+
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
34+
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
35+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
36+
INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
37+
MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
38+
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
39+
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
40+
POSSIBILITY OF SUCH DAMAGE.
41+
42+
Copyright (C) 2017 Apple Inc. All Rights Reserved.

UserInterface3DTransforms/README.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# User Interface 3D Transforms
2+
3+
This sample code demonstrates applying 3D effects to an arbitrary UIView. A few different views are chosen randomly to facilitate this example: images, a map view, and a web view. A view hierarchy is shown that is akin to the tab switching user experience in Safari on iOS and the 3D nature of this effect is implemented using CALayer's CATransform3D.
4+
5+
Note regarding touch input:
6+
7+
Views that handle touch input continue to function normally while in the "switcher" mode by default in this sample code, and by that, they respond to touch input while transformed in 3D space. There are occasions where this might be desired bahavior, but in cases where it is not, set SwitcherView.enableUserInteractionInSwitcher to false.
8+
9+
## Requirements
10+
11+
### Build
12+
13+
Xcode 6 or later
14+
15+
### Runtime
16+
17+
iOS 8 or later
18+
19+
Copyright (C) 2015 Apple Inc. All rights reserved.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,321 @@
1+
// !$*UTF8*$!
2+
{
3+
archiveVersion = 1;
4+
classes = {
5+
};
6+
objectVersion = 46;
7+
objects = {
8+
9+
/* Begin PBXBuildFile section */
10+
30294F2E1E8594F1008AA164 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30294F2D1E8594F1008AA164 /* AppDelegate.swift */; };
11+
30294F301E8594F1008AA164 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30294F2F1E8594F1008AA164 /* ViewController.swift */; };
12+
30294F331E8594F1008AA164 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 30294F311E8594F1008AA164 /* Main.storyboard */; };
13+
30294F351E8594F1008AA164 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 30294F341E8594F1008AA164 /* Assets.xcassets */; };
14+
30294F381E8594F1008AA164 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 30294F361E8594F1008AA164 /* LaunchScreen.storyboard */; };
15+
30294F461E8595F8008AA164 /* SwitcherView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30294F451E8595F8008AA164 /* SwitcherView.swift */; };
16+
30294F481E85C3FD008AA164 /* ContainerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30294F471E85C3FD008AA164 /* ContainerView.swift */; };
17+
/* End PBXBuildFile section */
18+
19+
/* Begin PBXFileReference section */
20+
30294F2A1E8594F1008AA164 /* UserInterface3DTransforms.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = UserInterface3DTransforms.app; sourceTree = BUILT_PRODUCTS_DIR; };
21+
30294F2D1E8594F1008AA164 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
22+
30294F2F1E8594F1008AA164 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
23+
30294F321E8594F1008AA164 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
24+
30294F341E8594F1008AA164 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
25+
30294F371E8594F1008AA164 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
26+
30294F391E8594F1008AA164 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
27+
30294F451E8595F8008AA164 /* SwitcherView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwitcherView.swift; sourceTree = "<group>"; };
28+
30294F471E85C3FD008AA164 /* ContainerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContainerView.swift; sourceTree = "<group>"; };
29+
30B7C1C51E89B07000C87C2A /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
30+
/* End PBXFileReference section */
31+
32+
/* Begin PBXFrameworksBuildPhase section */
33+
30294F271E8594F1008AA164 /* Frameworks */ = {
34+
isa = PBXFrameworksBuildPhase;
35+
buildActionMask = 2147483647;
36+
files = (
37+
);
38+
runOnlyForDeploymentPostprocessing = 0;
39+
};
40+
/* End PBXFrameworksBuildPhase section */
41+
42+
/* Begin PBXGroup section */
43+
30294F211E8594F1008AA164 = {
44+
isa = PBXGroup;
45+
children = (
46+
30B7C1C51E89B07000C87C2A /* README.md */,
47+
30294F2C1E8594F1008AA164 /* UserInterface3DTransforms */,
48+
30294F2B1E8594F1008AA164 /* Products */,
49+
);
50+
sourceTree = "<group>";
51+
};
52+
30294F2B1E8594F1008AA164 /* Products */ = {
53+
isa = PBXGroup;
54+
children = (
55+
30294F2A1E8594F1008AA164 /* UserInterface3DTransforms.app */,
56+
);
57+
name = Products;
58+
sourceTree = "<group>";
59+
};
60+
30294F2C1E8594F1008AA164 /* UserInterface3DTransforms */ = {
61+
isa = PBXGroup;
62+
children = (
63+
30294F2D1E8594F1008AA164 /* AppDelegate.swift */,
64+
30294F2F1E8594F1008AA164 /* ViewController.swift */,
65+
30294F451E8595F8008AA164 /* SwitcherView.swift */,
66+
30294F471E85C3FD008AA164 /* ContainerView.swift */,
67+
30294F311E8594F1008AA164 /* Main.storyboard */,
68+
30294F341E8594F1008AA164 /* Assets.xcassets */,
69+
30294F361E8594F1008AA164 /* LaunchScreen.storyboard */,
70+
30294F391E8594F1008AA164 /* Info.plist */,
71+
);
72+
path = UserInterface3DTransforms;
73+
sourceTree = "<group>";
74+
};
75+
/* End PBXGroup section */
76+
77+
/* Begin PBXNativeTarget section */
78+
30294F291E8594F1008AA164 /* UserInterface3DTransforms */ = {
79+
isa = PBXNativeTarget;
80+
buildConfigurationList = 30294F3C1E8594F1008AA164 /* Build configuration list for PBXNativeTarget "UserInterface3DTransforms" */;
81+
buildPhases = (
82+
30294F261E8594F1008AA164 /* Sources */,
83+
30294F271E8594F1008AA164 /* Frameworks */,
84+
30294F281E8594F1008AA164 /* Resources */,
85+
);
86+
buildRules = (
87+
);
88+
dependencies = (
89+
);
90+
name = UserInterface3DTransforms;
91+
productName = UserInterface3DTransforms;
92+
productReference = 30294F2A1E8594F1008AA164 /* UserInterface3DTransforms.app */;
93+
productType = "com.apple.product-type.application";
94+
};
95+
/* End PBXNativeTarget section */
96+
97+
/* Begin PBXProject section */
98+
30294F221E8594F1008AA164 /* Project object */ = {
99+
isa = PBXProject;
100+
attributes = {
101+
LastSwiftUpdateCheck = 0820;
102+
LastUpgradeCheck = 0820;
103+
ORGANIZATIONNAME = Apple;
104+
TargetAttributes = {
105+
30294F291E8594F1008AA164 = {
106+
CreatedOnToolsVersion = 8.2.1;
107+
ProvisioningStyle = Automatic;
108+
};
109+
};
110+
};
111+
buildConfigurationList = 30294F251E8594F1008AA164 /* Build configuration list for PBXProject "UserInterface3DTransforms" */;
112+
compatibilityVersion = "Xcode 3.2";
113+
developmentRegion = English;
114+
hasScannedForEncodings = 0;
115+
knownRegions = (
116+
en,
117+
Base,
118+
);
119+
mainGroup = 30294F211E8594F1008AA164;
120+
productRefGroup = 30294F2B1E8594F1008AA164 /* Products */;
121+
projectDirPath = "";
122+
projectRoot = "";
123+
targets = (
124+
30294F291E8594F1008AA164 /* UserInterface3DTransforms */,
125+
);
126+
};
127+
/* End PBXProject section */
128+
129+
/* Begin PBXResourcesBuildPhase section */
130+
30294F281E8594F1008AA164 /* Resources */ = {
131+
isa = PBXResourcesBuildPhase;
132+
buildActionMask = 2147483647;
133+
files = (
134+
30294F381E8594F1008AA164 /* LaunchScreen.storyboard in Resources */,
135+
30294F351E8594F1008AA164 /* Assets.xcassets in Resources */,
136+
30294F331E8594F1008AA164 /* Main.storyboard in Resources */,
137+
);
138+
runOnlyForDeploymentPostprocessing = 0;
139+
};
140+
/* End PBXResourcesBuildPhase section */
141+
142+
/* Begin PBXSourcesBuildPhase section */
143+
30294F261E8594F1008AA164 /* Sources */ = {
144+
isa = PBXSourcesBuildPhase;
145+
buildActionMask = 2147483647;
146+
files = (
147+
30294F481E85C3FD008AA164 /* ContainerView.swift in Sources */,
148+
30294F301E8594F1008AA164 /* ViewController.swift in Sources */,
149+
30294F461E8595F8008AA164 /* SwitcherView.swift in Sources */,
150+
30294F2E1E8594F1008AA164 /* AppDelegate.swift in Sources */,
151+
);
152+
runOnlyForDeploymentPostprocessing = 0;
153+
};
154+
/* End PBXSourcesBuildPhase section */
155+
156+
/* Begin PBXVariantGroup section */
157+
30294F311E8594F1008AA164 /* Main.storyboard */ = {
158+
isa = PBXVariantGroup;
159+
children = (
160+
30294F321E8594F1008AA164 /* Base */,
161+
);
162+
name = Main.storyboard;
163+
sourceTree = "<group>";
164+
};
165+
30294F361E8594F1008AA164 /* LaunchScreen.storyboard */ = {
166+
isa = PBXVariantGroup;
167+
children = (
168+
30294F371E8594F1008AA164 /* Base */,
169+
);
170+
name = LaunchScreen.storyboard;
171+
sourceTree = "<group>";
172+
};
173+
/* End PBXVariantGroup section */
174+
175+
/* Begin XCBuildConfiguration section */
176+
30294F3A1E8594F1008AA164 /* Debug */ = {
177+
isa = XCBuildConfiguration;
178+
buildSettings = {
179+
ALWAYS_SEARCH_USER_PATHS = NO;
180+
CLANG_ANALYZER_NONNULL = YES;
181+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
182+
CLANG_CXX_LIBRARY = "libc++";
183+
CLANG_ENABLE_MODULES = YES;
184+
CLANG_ENABLE_OBJC_ARC = YES;
185+
CLANG_WARN_BOOL_CONVERSION = YES;
186+
CLANG_WARN_CONSTANT_CONVERSION = YES;
187+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
188+
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
189+
CLANG_WARN_EMPTY_BODY = YES;
190+
CLANG_WARN_ENUM_CONVERSION = YES;
191+
CLANG_WARN_INFINITE_RECURSION = YES;
192+
CLANG_WARN_INT_CONVERSION = YES;
193+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
194+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
195+
CLANG_WARN_UNREACHABLE_CODE = YES;
196+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
197+
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
198+
COPY_PHASE_STRIP = NO;
199+
DEBUG_INFORMATION_FORMAT = dwarf;
200+
ENABLE_STRICT_OBJC_MSGSEND = YES;
201+
ENABLE_TESTABILITY = YES;
202+
GCC_C_LANGUAGE_STANDARD = gnu99;
203+
GCC_DYNAMIC_NO_PIC = NO;
204+
GCC_NO_COMMON_BLOCKS = YES;
205+
GCC_OPTIMIZATION_LEVEL = 0;
206+
GCC_PREPROCESSOR_DEFINITIONS = (
207+
"DEBUG=1",
208+
"$(inherited)",
209+
);
210+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
211+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
212+
GCC_WARN_UNDECLARED_SELECTOR = YES;
213+
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
214+
GCC_WARN_UNUSED_FUNCTION = YES;
215+
GCC_WARN_UNUSED_VARIABLE = YES;
216+
IPHONEOS_DEPLOYMENT_TARGET = 10.2;
217+
MTL_ENABLE_DEBUG_INFO = YES;
218+
ONLY_ACTIVE_ARCH = YES;
219+
SDKROOT = iphoneos;
220+
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
221+
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
222+
TARGETED_DEVICE_FAMILY = "1,2";
223+
};
224+
name = Debug;
225+
};
226+
30294F3B1E8594F1008AA164 /* Release */ = {
227+
isa = XCBuildConfiguration;
228+
buildSettings = {
229+
ALWAYS_SEARCH_USER_PATHS = NO;
230+
CLANG_ANALYZER_NONNULL = YES;
231+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
232+
CLANG_CXX_LIBRARY = "libc++";
233+
CLANG_ENABLE_MODULES = YES;
234+
CLANG_ENABLE_OBJC_ARC = YES;
235+
CLANG_WARN_BOOL_CONVERSION = YES;
236+
CLANG_WARN_CONSTANT_CONVERSION = YES;
237+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
238+
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
239+
CLANG_WARN_EMPTY_BODY = YES;
240+
CLANG_WARN_ENUM_CONVERSION = YES;
241+
CLANG_WARN_INFINITE_RECURSION = YES;
242+
CLANG_WARN_INT_CONVERSION = YES;
243+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
244+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
245+
CLANG_WARN_UNREACHABLE_CODE = YES;
246+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
247+
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
248+
COPY_PHASE_STRIP = NO;
249+
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
250+
ENABLE_NS_ASSERTIONS = NO;
251+
ENABLE_STRICT_OBJC_MSGSEND = YES;
252+
GCC_C_LANGUAGE_STANDARD = gnu99;
253+
GCC_NO_COMMON_BLOCKS = YES;
254+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
255+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
256+
GCC_WARN_UNDECLARED_SELECTOR = YES;
257+
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
258+
GCC_WARN_UNUSED_FUNCTION = YES;
259+
GCC_WARN_UNUSED_VARIABLE = YES;
260+
IPHONEOS_DEPLOYMENT_TARGET = 10.2;
261+
MTL_ENABLE_DEBUG_INFO = NO;
262+
SDKROOT = iphoneos;
263+
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
264+
TARGETED_DEVICE_FAMILY = "1,2";
265+
VALIDATE_PRODUCT = YES;
266+
};
267+
name = Release;
268+
};
269+
30294F3D1E8594F1008AA164 /* Debug */ = {
270+
isa = XCBuildConfiguration;
271+
buildSettings = {
272+
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
273+
DEVELOPMENT_TEAM = "";
274+
INFOPLIST_FILE = UserInterface3DTransforms/Info.plist;
275+
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
276+
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
277+
PRODUCT_BUNDLE_IDENTIFIER = "com.example.apple-samplecode.UserInterface3DTransforms";
278+
PRODUCT_NAME = "$(TARGET_NAME)";
279+
SWIFT_VERSION = 3.0;
280+
};
281+
name = Debug;
282+
};
283+
30294F3E1E8594F1008AA164 /* Release */ = {
284+
isa = XCBuildConfiguration;
285+
buildSettings = {
286+
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
287+
DEVELOPMENT_TEAM = "";
288+
INFOPLIST_FILE = UserInterface3DTransforms/Info.plist;
289+
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
290+
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
291+
PRODUCT_BUNDLE_IDENTIFIER = "com.example.apple-samplecode.UserInterface3DTransforms";
292+
PRODUCT_NAME = "$(TARGET_NAME)";
293+
SWIFT_VERSION = 3.0;
294+
};
295+
name = Release;
296+
};
297+
/* End XCBuildConfiguration section */
298+
299+
/* Begin XCConfigurationList section */
300+
30294F251E8594F1008AA164 /* Build configuration list for PBXProject "UserInterface3DTransforms" */ = {
301+
isa = XCConfigurationList;
302+
buildConfigurations = (
303+
30294F3A1E8594F1008AA164 /* Debug */,
304+
30294F3B1E8594F1008AA164 /* Release */,
305+
);
306+
defaultConfigurationIsVisible = 0;
307+
defaultConfigurationName = Release;
308+
};
309+
30294F3C1E8594F1008AA164 /* Build configuration list for PBXNativeTarget "UserInterface3DTransforms" */ = {
310+
isa = XCConfigurationList;
311+
buildConfigurations = (
312+
30294F3D1E8594F1008AA164 /* Debug */,
313+
30294F3E1E8594F1008AA164 /* Release */,
314+
);
315+
defaultConfigurationIsVisible = 0;
316+
defaultConfigurationName = Release;
317+
};
318+
/* End XCConfigurationList section */
319+
};
320+
rootObject = 30294F221E8594F1008AA164 /* Project object */;
321+
}

0 commit comments

Comments
 (0)