Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added sample for http://bitly.com/NqcE6n

  • Loading branch information...
commit 3d33da577f9c65e945a6f0a93dd34e0dbeb06454 1 parent b43dd43
@Cocoanetics authored
View
291 CoreAnimationBox/threedee2.xcodeproj/project.pbxproj
@@ -0,0 +1,291 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 46;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ A7A59B8815D6F27E00586456 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A7A59B8715D6F27E00586456 /* UIKit.framework */; };
+ A7A59B8A15D6F27E00586456 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A7A59B8915D6F27E00586456 /* Foundation.framework */; };
+ A7A59B8C15D6F27E00586456 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A7A59B8B15D6F27E00586456 /* CoreGraphics.framework */; };
+ A7A59B9215D6F27E00586456 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = A7A59B9015D6F27E00586456 /* InfoPlist.strings */; };
+ A7A59B9415D6F27E00586456 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = A7A59B9315D6F27E00586456 /* main.m */; };
+ A7A59B9815D6F27E00586456 /* DTAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A7A59B9715D6F27E00586456 /* DTAppDelegate.m */; };
+ A7A59B9B15D6F27E00586456 /* DTViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A7A59B9A15D6F27E00586456 /* DTViewController.m */; };
+ A7A59B9E15D6F27E00586456 /* DTViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A7A59B9C15D6F27E00586456 /* DTViewController.xib */; };
+ A7A59BA515D6F36700586456 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A7A59BA415D6F36700586456 /* QuartzCore.framework */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXFileReference section */
+ A7A59B8315D6F27E00586456 /* threedee2.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = threedee2.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ A7A59B8715D6F27E00586456 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
+ A7A59B8915D6F27E00586456 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
+ A7A59B8B15D6F27E00586456 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
+ A7A59B8F15D6F27E00586456 /* threedee2-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "threedee2-Info.plist"; sourceTree = "<group>"; };
+ A7A59B9115D6F27E00586456 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+ A7A59B9315D6F27E00586456 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
+ A7A59B9515D6F27E00586456 /* threedee2-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "threedee2-Prefix.pch"; sourceTree = "<group>"; };
+ A7A59B9615D6F27E00586456 /* DTAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DTAppDelegate.h; sourceTree = "<group>"; };
+ A7A59B9715D6F27E00586456 /* DTAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DTAppDelegate.m; sourceTree = "<group>"; };
+ A7A59B9915D6F27E00586456 /* DTViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DTViewController.h; sourceTree = "<group>"; };
+ A7A59B9A15D6F27E00586456 /* DTViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DTViewController.m; sourceTree = "<group>"; };
+ A7A59B9D15D6F27E00586456 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/DTViewController.xib; sourceTree = "<group>"; };
+ A7A59BA415D6F36700586456 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ A7A59B8015D6F27E00586456 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ A7A59BA515D6F36700586456 /* QuartzCore.framework in Frameworks */,
+ A7A59B8815D6F27E00586456 /* UIKit.framework in Frameworks */,
+ A7A59B8A15D6F27E00586456 /* Foundation.framework in Frameworks */,
+ A7A59B8C15D6F27E00586456 /* CoreGraphics.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ A7A59B7815D6F27D00586456 = {
+ isa = PBXGroup;
+ children = (
+ A7A59B8D15D6F27E00586456 /* threedee2 */,
+ A7A59B8615D6F27E00586456 /* Frameworks */,
+ A7A59B8415D6F27E00586456 /* Products */,
+ );
+ sourceTree = "<group>";
+ };
+ A7A59B8415D6F27E00586456 /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ A7A59B8315D6F27E00586456 /* threedee2.app */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+ A7A59B8615D6F27E00586456 /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ A7A59BA415D6F36700586456 /* QuartzCore.framework */,
+ A7A59B8715D6F27E00586456 /* UIKit.framework */,
+ A7A59B8915D6F27E00586456 /* Foundation.framework */,
+ A7A59B8B15D6F27E00586456 /* CoreGraphics.framework */,
+ );
+ name = Frameworks;
+ sourceTree = "<group>";
+ };
+ A7A59B8D15D6F27E00586456 /* threedee2 */ = {
+ isa = PBXGroup;
+ children = (
+ A7A59B9615D6F27E00586456 /* DTAppDelegate.h */,
+ A7A59B9715D6F27E00586456 /* DTAppDelegate.m */,
+ A7A59B9915D6F27E00586456 /* DTViewController.h */,
+ A7A59B9A15D6F27E00586456 /* DTViewController.m */,
+ A7A59B9C15D6F27E00586456 /* DTViewController.xib */,
+ A7A59B8E15D6F27E00586456 /* Supporting Files */,
+ );
+ path = threedee2;
+ sourceTree = "<group>";
+ };
+ A7A59B8E15D6F27E00586456 /* Supporting Files */ = {
+ isa = PBXGroup;
+ children = (
+ A7A59B8F15D6F27E00586456 /* threedee2-Info.plist */,
+ A7A59B9015D6F27E00586456 /* InfoPlist.strings */,
+ A7A59B9315D6F27E00586456 /* main.m */,
+ A7A59B9515D6F27E00586456 /* threedee2-Prefix.pch */,
+ );
+ name = "Supporting Files";
+ sourceTree = "<group>";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ A7A59B8215D6F27E00586456 /* threedee2 */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = A7A59BA115D6F27E00586456 /* Build configuration list for PBXNativeTarget "threedee2" */;
+ buildPhases = (
+ A7A59B7F15D6F27E00586456 /* Sources */,
+ A7A59B8015D6F27E00586456 /* Frameworks */,
+ A7A59B8115D6F27E00586456 /* Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = threedee2;
+ productName = threedee2;
+ productReference = A7A59B8315D6F27E00586456 /* threedee2.app */;
+ productType = "com.apple.product-type.application";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ A7A59B7A15D6F27D00586456 /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ CLASSPREFIX = DT;
+ LastUpgradeCheck = 0440;
+ ORGANIZATIONNAME = "Oliver Drobnik";
+ };
+ buildConfigurationList = A7A59B7D15D6F27D00586456 /* Build configuration list for PBXProject "threedee2" */;
+ compatibilityVersion = "Xcode 3.2";
+ developmentRegion = English;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ );
+ mainGroup = A7A59B7815D6F27D00586456;
+ productRefGroup = A7A59B8415D6F27E00586456 /* Products */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ A7A59B8215D6F27E00586456 /* threedee2 */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ A7A59B8115D6F27E00586456 /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ A7A59B9215D6F27E00586456 /* InfoPlist.strings in Resources */,
+ A7A59B9E15D6F27E00586456 /* DTViewController.xib in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ A7A59B7F15D6F27E00586456 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ A7A59B9415D6F27E00586456 /* main.m in Sources */,
+ A7A59B9815D6F27E00586456 /* DTAppDelegate.m in Sources */,
+ A7A59B9B15D6F27E00586456 /* DTViewController.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXVariantGroup section */
+ A7A59B9015D6F27E00586456 /* InfoPlist.strings */ = {
+ isa = PBXVariantGroup;
+ children = (
+ A7A59B9115D6F27E00586456 /* en */,
+ );
+ name = InfoPlist.strings;
+ sourceTree = "<group>";
+ };
+ A7A59B9C15D6F27E00586456 /* DTViewController.xib */ = {
+ isa = PBXVariantGroup;
+ children = (
+ A7A59B9D15D6F27E00586456 /* en */,
+ );
+ name = DTViewController.xib;
+ sourceTree = "<group>";
+ };
+/* End PBXVariantGroup section */
+
+/* Begin XCBuildConfiguration section */
+ A7A59B9F15D6F27E00586456 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ COPY_PHASE_STRIP = NO;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "DEBUG=1",
+ "$(inherited)",
+ );
+ GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 5.1;
+ SDKROOT = iphoneos;
+ };
+ name = Debug;
+ };
+ A7A59BA015D6F27E00586456 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ COPY_PHASE_STRIP = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 5.1;
+ OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
+ SDKROOT = iphoneos;
+ VALIDATE_PRODUCT = YES;
+ };
+ name = Release;
+ };
+ A7A59BA215D6F27E00586456 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "threedee2/threedee2-Prefix.pch";
+ INFOPLIST_FILE = "threedee2/threedee2-Info.plist";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ WRAPPER_EXTENSION = app;
+ };
+ name = Debug;
+ };
+ A7A59BA315D6F27E00586456 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "threedee2/threedee2-Prefix.pch";
+ INFOPLIST_FILE = "threedee2/threedee2-Info.plist";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ WRAPPER_EXTENSION = app;
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ A7A59B7D15D6F27D00586456 /* Build configuration list for PBXProject "threedee2" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ A7A59B9F15D6F27E00586456 /* Debug */,
+ A7A59BA015D6F27E00586456 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ A7A59BA115D6F27E00586456 /* Build configuration list for PBXNativeTarget "threedee2" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ A7A59BA215D6F27E00586456 /* Debug */,
+ A7A59BA315D6F27E00586456 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = A7A59B7A15D6F27D00586456 /* Project object */;
+}
View
19 CoreAnimationBox/threedee2/DTAppDelegate.h
@@ -0,0 +1,19 @@
+//
+// DTAppDelegate.h
+// threedee2
+//
+// Created by Oliver Drobnik on 11.08.12.
+// Copyright (c) 2012 Oliver Drobnik. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@class DTViewController;
+
+@interface DTAppDelegate : UIResponder <UIApplicationDelegate>
+
+@property (strong, nonatomic) UIWindow *window;
+
+@property (strong, nonatomic) DTViewController *viewController;
+
+@end
View
52 CoreAnimationBox/threedee2/DTAppDelegate.m
@@ -0,0 +1,52 @@
+//
+// DTAppDelegate.m
+// threedee2
+//
+// Created by Oliver Drobnik on 11.08.12.
+// Copyright (c) 2012 Oliver Drobnik. All rights reserved.
+//
+
+#import "DTAppDelegate.h"
+
+#import "DTViewController.h"
+
+@implementation DTAppDelegate
+
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
+{
+ self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
+ // Override point for customization after application launch.
+ self.viewController = [[DTViewController alloc] initWithNibName:@"DTViewController" bundle:nil];
+ self.window.rootViewController = self.viewController;
+ [self.window makeKeyAndVisible];
+ return YES;
+}
+
+- (void)applicationWillResignActive:(UIApplication *)application
+{
+ // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
+ // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
+}
+
+- (void)applicationDidEnterBackground:(UIApplication *)application
+{
+ // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
+ // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
+}
+
+- (void)applicationWillEnterForeground:(UIApplication *)application
+{
+ // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
+}
+
+- (void)applicationDidBecomeActive:(UIApplication *)application
+{
+ // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
+}
+
+- (void)applicationWillTerminate:(UIApplication *)application
+{
+ // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
+}
+
+@end
View
13 CoreAnimationBox/threedee2/DTViewController.h
@@ -0,0 +1,13 @@
+//
+// DTViewController.h
+// threedee2
+//
+// Created by Oliver Drobnik on 11.08.12.
+// Copyright (c) 2012 Oliver Drobnik. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface DTViewController : UIViewController
+
+@end
View
190 CoreAnimationBox/threedee2/DTViewController.m
@@ -0,0 +1,190 @@
+//
+// DTViewController.m
+// threedee2
+//
+// Created by Oliver Drobnik on 11.08.12.
+// Copyright (c) 2012 Oliver Drobnik. All rights reserved.
+//
+
+#import "DTViewController.h"
+#import <QuartzCore/QuartzCore.h>
+
+@interface DTViewController ()
+
+@end
+
+@implementation DTViewController
+{
+ CATransformLayer *baseLayer;
+ CALayer *greenLayer;
+ CALayer *magentaLayer;
+ CALayer *blueLayer;
+ CALayer *yellowLayer;
+ CALayer *purpleLayer;
+
+ BOOL isThreeDee;
+}
+
+- (void)viewDidLoad
+{
+ [super viewDidLoad];
+
+ UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(pan:)];
+ [self.view addGestureRecognizer:pan];
+
+ UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap:)];
+ [self.view addGestureRecognizer:tap];
+
+ UIPinchGestureRecognizer *pinch = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinch:)];
+ [self.view addGestureRecognizer:pinch];
+
+ self.view.backgroundColor = [UIColor blackColor];
+
+ baseLayer = [CATransformLayer layer];
+ baseLayer.anchorPoint = CGPointZero;
+ baseLayer.bounds = self.view.bounds;
+ baseLayer.position = CGPointMake(CGRectGetMidX(self.view.bounds), CGRectGetMidY(self.view.bounds));
+
+ [self.view.layer addSublayer:baseLayer];
+
+ CALayer *redLayer = [CALayer layer];
+ redLayer.backgroundColor = [UIColor redColor].CGColor;
+ redLayer.frame = CGRectMake(0, 0, 100, 100);
+ redLayer.position = CGPointMake(0,0);
+ [baseLayer addSublayer:redLayer];
+
+ blueLayer = [CALayer layer];
+ blueLayer.backgroundColor = [UIColor blueColor].CGColor;
+ blueLayer.bounds = CGRectMake(0, 0, 100, 100);
+ blueLayer.anchorPoint = CGPointMake(1, 0.5); // right
+ blueLayer.position = CGPointMake(-50,0);
+ [baseLayer addSublayer:blueLayer];
+
+ yellowLayer = [CALayer layer];
+ yellowLayer.backgroundColor = [UIColor purpleColor].CGColor;
+ yellowLayer.bounds = CGRectMake(0, 0, 100, 100);
+ yellowLayer.anchorPoint = CGPointMake(0.5, 1); // bottom
+ yellowLayer.position = CGPointMake(0,-50);
+ [baseLayer addSublayer:yellowLayer];
+
+ purpleLayer = [CALayer layer];
+ purpleLayer.backgroundColor = [UIColor yellowColor].CGColor;
+ purpleLayer.bounds = CGRectMake(0, 0, 100, 100);
+ purpleLayer.anchorPoint = CGPointMake(0.5, 0); // top
+ purpleLayer.position = CGPointMake(0,50);
+ [baseLayer addSublayer:purpleLayer];
+
+ // need a transform layer for green to mount magenta on
+ greenLayer = [CATransformLayer layer];
+ greenLayer.bounds = CGRectMake(0, 0, 100, 100);
+ greenLayer.anchorPoint = CGPointMake(0, 0.5); // left
+ greenLayer.position = CGPointMake(50,0);
+ [baseLayer addSublayer:greenLayer];
+
+ CALayer *greenSolidLayer = [CALayer layer];
+ greenSolidLayer.backgroundColor = [UIColor greenColor].CGColor;
+ greenSolidLayer.bounds = CGRectMake(0, 0, 100, 100);
+ greenSolidLayer.anchorPoint = CGPointMake(0, 0); // top left
+ greenSolidLayer.position = CGPointMake(0,0);
+ [greenLayer addSublayer:greenSolidLayer];
+
+ // the "lid"
+ magentaLayer = [CALayer layer];
+ magentaLayer.backgroundColor = [UIColor magentaColor].CGColor;
+ magentaLayer.bounds = CGRectMake(0, 0, 100, 100);
+ magentaLayer.anchorPoint = CGPointMake(0, 0.5); // left
+ magentaLayer.position = CGPointMake(100,50);
+ [greenLayer addSublayer:magentaLayer];
+
+ CATransform3D initialTransform = baseLayer.sublayerTransform;
+ initialTransform.m34 = 1.0 / -1200;
+ baseLayer.sublayerTransform = initialTransform;
+}
+
+- (void)pan:(UIPanGestureRecognizer *)gesture
+{
+ if (gesture.state == UIGestureRecognizerStateChanged)
+ {
+ CGPoint displacement = [gesture translationInView:self.view.superview];
+ CATransform3D currentTransform = baseLayer.sublayerTransform;
+
+ if (displacement.x==0 && displacement.y==0)
+ {
+ // no rotation, nothing to do
+ return;
+ }
+
+ CGFloat totalRotation = sqrt(displacement.x * displacement.x + displacement.y * displacement.y) * M_PI / 180.0;
+ CGFloat xRotationFactor = displacement.x/totalRotation;
+ CGFloat yRotationFactor = displacement.y/totalRotation;
+
+
+ if (isThreeDee)
+ {
+ currentTransform = CATransform3DTranslate(currentTransform, 0, 0, 50);
+ }
+
+ CATransform3D rotationalTransform = CATransform3DRotate(currentTransform, totalRotation,
+ (xRotationFactor * currentTransform.m12 - yRotationFactor * currentTransform.m11),
+ (xRotationFactor * currentTransform.m22 - yRotationFactor * currentTransform.m21),
+ (xRotationFactor * currentTransform.m32 - yRotationFactor * currentTransform.m31));
+
+ if (isThreeDee)
+ {
+ rotationalTransform = CATransform3DTranslate(rotationalTransform, 0, 0, -50);
+ }
+
+ [CATransaction setAnimationDuration:0];
+
+ baseLayer.sublayerTransform = rotationalTransform;
+
+
+ [gesture setTranslation:CGPointZero inView:self.view];
+ }
+}
+
+- (void)tap:(UITapGestureRecognizer *)gesture
+{
+ isThreeDee = !isThreeDee;
+
+ if (isThreeDee)
+ {
+ greenLayer.transform = CATransform3DMakeRotation(-M_PI_2, 0, 1, 0);
+ blueLayer.transform = CATransform3DMakeRotation(M_PI_2, 0, 1, 0);
+ yellowLayer.transform = CATransform3DMakeRotation(-M_PI_2, 1, 0, 0);
+ purpleLayer.transform = CATransform3DMakeRotation(M_PI_2, 1, 0, 0);
+ magentaLayer.transform = CATransform3DMakeRotation(0.8*-M_PI_2, 0, 1, 0);
+ }
+ else
+ {
+ greenLayer.transform = CATransform3DIdentity;
+ blueLayer.transform = CATransform3DIdentity;
+ yellowLayer.transform = CATransform3DIdentity;
+ purpleLayer.transform = CATransform3DIdentity;
+ magentaLayer.transform = CATransform3DIdentity;
+ }
+}
+
+- (void)pinch:(UIPinchGestureRecognizer *)pinch
+{
+ if (pinch.state == UIGestureRecognizerStateChanged)
+ {
+ // currentTransform = baseLayer.sublayerTransform;
+
+ NSLog(@"%f", pinch.scale);
+ }
+}
+
+- (void)viewDidUnload
+{
+ [super viewDidUnload];
+ // Release any retained subviews of the main view.
+}
+
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
+{
+ return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
+}
+
+
+@end
View
119 CoreAnimationBox/threedee2/en.lproj/DTViewController.xib
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="8.00">
+ <data>
+ <int key="IBDocument.SystemTarget">1280</int>
+ <string key="IBDocument.SystemVersion">11C25</string>
+ <string key="IBDocument.InterfaceBuilderVersion">1919</string>
+ <string key="IBDocument.AppKitVersion">1138.11</string>
+ <string key="IBDocument.HIToolboxVersion">566.00</string>
+ <object class="NSMutableDictionary" key="IBDocument.PluginVersions">
+ <string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string key="NS.object.0">916</string>
+ </object>
+ <array key="IBDocument.IntegratedClassDependencies">
+ <string>IBProxyObject</string>
+ <string>IBUIView</string>
+ </array>
+ <array key="IBDocument.PluginDependencies">
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ </array>
+ <object class="NSMutableDictionary" key="IBDocument.Metadata">
+ <string key="NS.key.0">PluginDependencyRecalculationVersion</string>
+ <integer value="1" key="NS.object.0"/>
+ </object>
+ <array class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
+ <object class="IBProxyObject" id="372490531">
+ <string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ </object>
+ <object class="IBProxyObject" id="843779117">
+ <string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ </object>
+ <object class="IBUIView" id="774585933">
+ <reference key="NSNextResponder"/>
+ <int key="NSvFlags">274</int>
+ <string key="NSFrame">{{0, 20}, {320, 460}}</string>
+ <reference key="NSSuperview"/>
+ <reference key="NSWindow"/>
+ <object class="NSColor" key="IBUIBackgroundColor">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MC43NQA</bytes>
+ <object class="NSColorSpace" key="NSCustomColorSpace">
+ <int key="NSID">2</int>
+ </object>
+ </object>
+ <bool key="IBUIClearsContextBeforeDrawing">NO</bool>
+ <object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/>
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ </object>
+ </array>
+ <object class="IBObjectContainer" key="IBDocument.Objects">
+ <array class="NSMutableArray" key="connectionRecords">
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchOutletConnection" key="connection">
+ <string key="label">view</string>
+ <reference key="source" ref="372490531"/>
+ <reference key="destination" ref="774585933"/>
+ </object>
+ <int key="connectionID">7</int>
+ </object>
+ </array>
+ <object class="IBMutableOrderedSet" key="objectRecords">
+ <array key="orderedObjects">
+ <object class="IBObjectRecord">
+ <int key="objectID">0</int>
+ <array key="object" id="0"/>
+ <reference key="children" ref="1000"/>
+ <nil key="parent"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">-1</int>
+ <reference key="object" ref="372490531"/>
+ <reference key="parent" ref="0"/>
+ <string key="objectName">File's Owner</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">-2</int>
+ <reference key="object" ref="843779117"/>
+ <reference key="parent" ref="0"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">6</int>
+ <reference key="object" ref="774585933"/>
+ <reference key="parent" ref="0"/>
+ </object>
+ </array>
+ </object>
+ <dictionary class="NSMutableDictionary" key="flattenedProperties">
+ <string key="-1.CustomClassName">DTViewController</string>
+ <string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string key="-2.CustomClassName">UIResponder</string>
+ <string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string key="6.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ </dictionary>
+ <dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
+ <nil key="activeLocalization"/>
+ <dictionary class="NSMutableDictionary" key="localizations"/>
+ <nil key="sourceID"/>
+ <int key="maxID">7</int>
+ </object>
+ <object class="IBClassDescriber" key="IBDocument.Classes">
+ <array class="NSMutableArray" key="referencedPartialClassDescriptions">
+ <object class="IBPartialClassDescription">
+ <string key="className">DTViewController</string>
+ <string key="superclassName">UIViewController</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">./Classes/DTViewController.h</string>
+ </object>
+ </object>
+ </array>
+ </object>
+ <int key="IBDocument.localizationMode">0</int>
+ <string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
+ <int key="IBDocument.defaultPropertyAccessControl">3</int>
+ <string key="IBCocoaTouchPluginVersion">916</string>
+ </data>
+</archive>
View
2  CoreAnimationBox/threedee2/en.lproj/InfoPlist.strings
@@ -0,0 +1,2 @@
+/* Localized versions of Info.plist keys */
+
View
18 CoreAnimationBox/threedee2/main.m
@@ -0,0 +1,18 @@
+//
+// main.m
+// threedee2
+//
+// Created by Oliver Drobnik on 11.08.12.
+// Copyright (c) 2012 Oliver Drobnik. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+#import "DTAppDelegate.h"
+
+int main(int argc, char *argv[])
+{
+ @autoreleasepool {
+ return UIApplicationMain(argc, argv, nil, NSStringFromClass([DTAppDelegate class]));
+ }
+}
View
38 CoreAnimationBox/threedee2/threedee2-Info.plist
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>en</string>
+ <key>CFBundleDisplayName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIdentifier</key>
+ <string>com.drobnik.${PRODUCT_NAME:rfc1034identifier}</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1.0</string>
+ <key>LSRequiresIPhoneOS</key>
+ <true/>
+ <key>UIRequiredDeviceCapabilities</key>
+ <array>
+ <string>armv7</string>
+ </array>
+ <key>UISupportedInterfaceOrientations</key>
+ <array>
+ <string>UIInterfaceOrientationPortrait</string>
+ <string>UIInterfaceOrientationLandscapeLeft</string>
+ <string>UIInterfaceOrientationLandscapeRight</string>
+ </array>
+</dict>
+</plist>
View
14 CoreAnimationBox/threedee2/threedee2-Prefix.pch
@@ -0,0 +1,14 @@
+//
+// Prefix header for all source files of the 'threedee2' target in the 'threedee2' project
+//
+
+#import <Availability.h>
+
+#ifndef __IPHONE_4_0
+#warning "This project uses features only available in iOS SDK 4.0 and later."
+#endif
+
+#ifdef __OBJC__
+ #import <UIKit/UIKit.h>
+ #import <Foundation/Foundation.h>
+#endif
Please sign in to comment.
Something went wrong with that request. Please try again.