Skip to content

Commit

Permalink
* Finished the layer content samples (displaying an image and drawin…
Browse files Browse the repository at this point in the history
…g to the context)

 * Reorganized the project Resources
  • Loading branch information
neror committed Aug 17, 2009
1 parent 03623e8 commit 0e4e41f
Show file tree
Hide file tree
Showing 14 changed files with 235 additions and 30 deletions.
74 changes: 53 additions & 21 deletions CA360.xcodeproj/project.pbxproj
Expand Up @@ -12,14 +12,25 @@
1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; };
2892E4100DC94CBA00A64D0F /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2892E40F0DC94CBA00A64D0F /* CoreGraphics.framework */; };
28AD73600D9D9599002E5188 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 28AD735F0D9D9599002E5188 /* MainWindow.xib */; };
28C286E10D94DF7D0034E888 /* RootViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 28C286E00D94DF7D0034E888 /* RootViewController.m */; };
DF80136D10377A1200B48250 /* GradientLayers.m in Sources */ = {isa = PBXBuildFile; fileRef = DF80136C10377A1200B48250 /* GradientLayers.m */; };
DF80136E10377A1200B48250 /* GradientLayers.m in Sources */ = {isa = PBXBuildFile; fileRef = DF80136C10377A1200B48250 /* GradientLayers.m */; };
DF8014A21038D12900B48250 /* CALayer+FTDebugDrawing.m in Sources */ = {isa = PBXBuildFile; fileRef = DF8014A11038D12900B48250 /* CALayer+FTDebugDrawing.m */; };
DF8014A31038D12900B48250 /* CALayer+FTDebugDrawing.m in Sources */ = {isa = PBXBuildFile; fileRef = DF8014A11038D12900B48250 /* CALayer+FTDebugDrawing.m */; };
DF8015621038E1C400B48250 /* LayerTransforms.m in Sources */ = {isa = PBXBuildFile; fileRef = DF8015611038E1C400B48250 /* LayerTransforms.m */; };
DF8015631038E1C400B48250 /* LayerTransforms.m in Sources */ = {isa = PBXBuildFile; fileRef = DF8015611038E1C400B48250 /* LayerTransforms.m */; };
DFF70C321039D8BC0052EE6A /* ImageContent.m in Sources */ = {isa = PBXBuildFile; fileRef = DFF70C311039D8BC0052EE6A /* ImageContent.m */; };
DFF70C331039D8BC0052EE6A /* ImageContent.m in Sources */ = {isa = PBXBuildFile; fileRef = DFF70C311039D8BC0052EE6A /* ImageContent.m */; };
DFF70C461039D9E60052EE6A /* FTSLogo.png in Resources */ = {isa = PBXBuildFile; fileRef = DFF70C451039D9E60052EE6A /* FTSLogo.png */; };
DFF70C471039D9E60052EE6A /* FTSLogo.png in Resources */ = {isa = PBXBuildFile; fileRef = DFF70C451039D9E60052EE6A /* FTSLogo.png */; };
DFF70C4F1039DA0A0052EE6A /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = DFF70C4C1039DA0A0052EE6A /* MainWindow.xib */; };
DFF70C511039DA0A0052EE6A /* UnitTests-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = DFF70C4B1039DA0A0052EE6A /* UnitTests-Info.plist */; };
DFF70C521039DA0A0052EE6A /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = DFF70C4C1039DA0A0052EE6A /* MainWindow.xib */; };
DFF70C531039DA0A0052EE6A /* CA360-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = DFF70C4D1039DA0A0052EE6A /* CA360-Info.plist */; };
DFF70C9E1039DE170052EE6A /* Ben.png in Resources */ = {isa = PBXBuildFile; fileRef = DFF70C9C1039DE170052EE6A /* Ben.png */; };
DFF70C9F1039DE170052EE6A /* Steve.png in Resources */ = {isa = PBXBuildFile; fileRef = DFF70C9D1039DE170052EE6A /* Steve.png */; };
DFF70CA01039DE170052EE6A /* Ben.png in Resources */ = {isa = PBXBuildFile; fileRef = DFF70C9C1039DE170052EE6A /* Ben.png */; };
DFF70CA11039DE170052EE6A /* Steve.png in Resources */ = {isa = PBXBuildFile; fileRef = DFF70C9D1039DE170052EE6A /* Steve.png */; };
DFF7F28D103601FE0067ED5B /* OCMock.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DFF7F28C103601FE0067ED5B /* OCMock.framework */; };
DFF7F2F5103602470067ED5B /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DFF7F2F4103602470067ED5B /* QuartzCore.framework */; };
DFF7F2F6103602470067ED5B /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DFF7F2F4103602470067ED5B /* QuartzCore.framework */; };
Expand Down Expand Up @@ -70,19 +81,24 @@
1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
2892E40F0DC94CBA00A64D0F /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
28A0AAE50D9B0CCF005BE974 /* CA360_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CA360_Prefix.pch; sourceTree = "<group>"; };
28AD735F0D9D9599002E5188 /* MainWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MainWindow.xib; sourceTree = "<group>"; };
28C286DF0D94DF7D0034E888 /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = "<group>"; };
28C286E00D94DF7D0034E888 /* RootViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RootViewController.m; sourceTree = "<group>"; };
29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
8D1107310486CEB800E47090 /* CA360-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "CA360-Info.plist"; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = "<group>"; };
DF80136B10377A1200B48250 /* GradientLayers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GradientLayers.h; path = Classes/Samples/GradientLayers.h; sourceTree = "<group>"; };
DF80136C10377A1200B48250 /* GradientLayers.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GradientLayers.m; path = Classes/Samples/GradientLayers.m; sourceTree = "<group>"; };
DF8014A01038D12900B48250 /* CALayer+FTDebugDrawing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "CALayer+FTDebugDrawing.h"; path = "Classes/CALayer+FTDebugDrawing.h"; sourceTree = "<group>"; };
DF8014A11038D12900B48250 /* CALayer+FTDebugDrawing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "CALayer+FTDebugDrawing.m"; path = "Classes/CALayer+FTDebugDrawing.m"; sourceTree = "<group>"; };
DF8015601038E1C400B48250 /* LayerTransforms.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LayerTransforms.h; path = Classes/Samples/LayerTransforms.h; sourceTree = "<group>"; };
DF8015611038E1C400B48250 /* LayerTransforms.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = LayerTransforms.m; path = Classes/Samples/LayerTransforms.m; sourceTree = "<group>"; };
DFF70C301039D8BC0052EE6A /* ImageContent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ImageContent.h; path = Classes/Samples/ImageContent.h; sourceTree = "<group>"; };
DFF70C311039D8BC0052EE6A /* ImageContent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ImageContent.m; path = Classes/Samples/ImageContent.m; sourceTree = "<group>"; };
DFF70C451039D9E60052EE6A /* FTSLogo.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = FTSLogo.png; sourceTree = "<group>"; };
DFF70C4B1039DA0A0052EE6A /* UnitTests-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "UnitTests-Info.plist"; sourceTree = "<group>"; };
DFF70C4C1039DA0A0052EE6A /* MainWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MainWindow.xib; sourceTree = "<group>"; };
DFF70C4D1039DA0A0052EE6A /* CA360-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = "CA360-Info.plist"; sourceTree = "<group>"; };
DFF70C9C1039DE170052EE6A /* Ben.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Ben.png; sourceTree = "<group>"; };
DFF70C9D1039DE170052EE6A /* Steve.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Steve.png; sourceTree = "<group>"; };
DFF7F25D103601B20067ED5B /* UnitTests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = UnitTests.octest; sourceTree = BUILT_PRODUCTS_DIR; };
DFF7F25E103601B20067ED5B /* UnitTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "UnitTests-Info.plist"; sourceTree = "<group>"; };
DFF7F28C103601FE0067ED5B /* OCMock.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = OCMock.framework; sourceTree = "<group>"; };
DFF7F2F4103602470067ED5B /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
DFF7F30B1036025B0067ED5B /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Developer/Library/Frameworks/SenTestingKit.framework; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -162,11 +178,10 @@
080E96DDFE201D6D7F000001 /* Core App Classes */,
DFF7F257103601A50067ED5B /* Tests */,
29B97315FDCFA39411CA2CEA /* Other Sources */,
29B97317FDCFA39411CA2CEA /* Resources */,
DFF70C441039D9E60052EE6A /* Resources */,
DFF7F28B103601FE0067ED5B /* Support */,
29B97323FDCFA39411CA2CEA /* Frameworks */,
19C28FACFE9D520D11CA2CBB /* Products */,
DFF7F25E103601B20067ED5B /* UnitTests-Info.plist */,
);
name = CustomTemplate;
sourceTree = "<group>";
Expand All @@ -180,15 +195,6 @@
name = "Other Sources";
sourceTree = "<group>";
};
29B97317FDCFA39411CA2CEA /* Resources */ = {
isa = PBXGroup;
children = (
28AD735F0D9D9599002E5188 /* MainWindow.xib */,
8D1107310486CEB800E47090 /* CA360-Info.plist */,
);
name = Resources;
sourceTree = "<group>";
};
29B97323FDCFA39411CA2CEA /* Frameworks */ = {
isa = PBXGroup;
children = (
Expand All @@ -200,6 +206,19 @@
name = Frameworks;
sourceTree = "<group>";
};
DFF70C441039D9E60052EE6A /* Resources */ = {
isa = PBXGroup;
children = (
DFF70C451039D9E60052EE6A /* FTSLogo.png */,
DFF70C9C1039DE170052EE6A /* Ben.png */,
DFF70C9D1039DE170052EE6A /* Steve.png */,
DFF70C4B1039DA0A0052EE6A /* UnitTests-Info.plist */,
DFF70C4C1039DA0A0052EE6A /* MainWindow.xib */,
DFF70C4D1039DA0A0052EE6A /* CA360-Info.plist */,
);
path = Resources;
sourceTree = "<group>";
};
DFF7F257103601A50067ED5B /* Tests */ = {
isa = PBXGroup;
children = (
Expand All @@ -224,7 +243,7 @@
children = (
DFF7F65C103635380067ED5B /* Geometry & Transforms */,
DFF7F65D1036354F0067ED5B /* Layer Hierarchy */,
DFF7F65E103635690067ED5B /* Drawing & Style Properties */,
DFF7F65E103635690067ED5B /* Content & Style Properties */,
DFF7F657103634AB0067ED5B /* Animation */,
DFF7F65F103635840067ED5B /* Special Layer Types */,
DFF7F3F4103606580067ED5B /* SynthesizeSingleton.h */,
Expand Down Expand Up @@ -267,13 +286,15 @@
name = "Layer Hierarchy";
sourceTree = "<group>";
};
DFF7F65E103635690067ED5B /* Drawing & Style Properties */ = {
DFF7F65E103635690067ED5B /* Content & Style Properties */ = {
isa = PBXGroup;
children = (
DFF70C301039D8BC0052EE6A /* ImageContent.h */,
DFF70C311039D8BC0052EE6A /* ImageContent.m */,
DFF7F610103632570067ED5B /* LayerDrawing.h */,
DFF7F611103632570067ED5B /* LayerDrawing.m */,
);
name = "Drawing & Style Properties";
name = "Content & Style Properties";
sourceTree = "<group>";
};
DFF7F65F103635840067ED5B /* Special Layer Types */ = {
Expand Down Expand Up @@ -356,14 +377,23 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
28AD73600D9D9599002E5188 /* MainWindow.xib in Resources */,
DFF70C461039D9E60052EE6A /* FTSLogo.png in Resources */,
DFF70C4F1039DA0A0052EE6A /* MainWindow.xib in Resources */,
DFF70C9E1039DE170052EE6A /* Ben.png in Resources */,
DFF70C9F1039DE170052EE6A /* Steve.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
DFF7F258103601B20067ED5B /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
DFF70C471039D9E60052EE6A /* FTSLogo.png in Resources */,
DFF70C511039DA0A0052EE6A /* UnitTests-Info.plist in Resources */,
DFF70C521039DA0A0052EE6A /* MainWindow.xib in Resources */,
DFF70C531039DA0A0052EE6A /* CA360-Info.plist in Resources */,
DFF70CA01039DE170052EE6A /* Ben.png in Resources */,
DFF70CA11039DE170052EE6A /* Steve.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -404,6 +434,7 @@
DF80136E10377A1200B48250 /* GradientLayers.m in Sources */,
DF8014A31038D12900B48250 /* CALayer+FTDebugDrawing.m in Sources */,
DF8015631038E1C400B48250 /* LayerTransforms.m in Sources */,
DFF70C321039D8BC0052EE6A /* ImageContent.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -424,6 +455,7 @@
DF80136D10377A1200B48250 /* GradientLayers.m in Sources */,
DF8014A21038D12900B48250 /* CALayer+FTDebugDrawing.m in Sources */,
DF8015621038E1C400B48250 /* LayerTransforms.m in Sources */,
DFF70C331039D8BC0052EE6A /* ImageContent.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -440,7 +472,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = CA360_Prefix.pch;
GCC_PREPROCESSOR_DEFINITIONS = "DEBUG=1";
INFOPLIST_FILE = "CA360-Info.plist";
INFOPLIST_FILE = "Resources/CA360-Info.plist";
PRODUCT_NAME = CA360;
};
name = Debug;
Expand Down Expand Up @@ -498,7 +530,7 @@
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREFIX_HEADER = CA360_Prefix.pch;
INFOPLIST_FILE = "UnitTests-Info.plist";
INFOPLIST_FILE = "Resources/UnitTests-Info.plist";
OTHER_LDFLAGS = (
"-framework",
Foundation,
Expand Down
2 changes: 1 addition & 1 deletion Classes/Samples/GeometryProperties.m
Expand Up @@ -68,7 +68,7 @@ - (void)loadView {
[myView addSubview:movePositionButton_];

propertiesTextView_ = [[UITextView alloc] initWithFrame:CGRectMake(0.f, 60.f, 320.f, 44.f)];
propertiesTextView_.backgroundColor = UIColorFromRGBA(0xFFFFFF, 0.f);
propertiesTextView_.backgroundColor = [UIColor clearColor];
propertiesTextView_.editable = NO;
propertiesTextView_.textAlignment = UITextAlignmentCenter;
propertiesTextView_.font = [UIFont systemFontOfSize:12.f];
Expand Down
34 changes: 34 additions & 0 deletions Classes/Samples/ImageContent.h
@@ -0,0 +1,34 @@
/*
The MIT License
Copyright (c) 2009 Free Time Studios and Nathan Eror
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

#import <UIKit/UIKit.h>

@interface ImageContent : UIViewController {
CALayer *simpleLayer_;
CALayer *moneyLayer_;

UIButton *magicButton_;
}

@end
113 changes: 113 additions & 0 deletions Classes/Samples/ImageContent.m
@@ -0,0 +1,113 @@
/*
The MIT License
Copyright (c) 2009 Free Time Studios and Nathan Eror
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

#import "ImageContent.h"
#import <QuartzCore/QuartzCore.h>

@implementation ImageContent

+ (NSString *)friendlyName {
return @"Image Content";
}

#pragma mark init and dealloc

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
self.title = [[self class] friendlyName];
}
return self;
}

- (void)dealloc {
FTRELEASE(simpleLayer_);
FTRELEASE(moneyLayer_);
[super dealloc];
}

#pragma mark Load and unload the view

- (void)loadView {
UIView *myView = [[[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
myView.backgroundColor = [UIColor grayColor];

magicButton_ = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
magicButton_.frame = CGRectMake(10.f, 10.f, 300.f, 44.f);
[magicButton_ setTitle:@"Invoke Magic!" forState:UIControlStateNormal];
[magicButton_ addTarget:self action:@selector(toggleMoney:) forControlEvents:UIControlEventTouchUpInside];
[myView addSubview:magicButton_];

simpleLayer_ = [[CALayer layer] retain];
moneyLayer_ = [[CALayer layer] retain];

[myView.layer addSublayer:simpleLayer_];
[myView.layer addSublayer:moneyLayer_];

self.view = myView;
}

- (void)viewDidUnload {
FTRELEASE(simpleLayer_);
FTRELEASE(moneyLayer_);
}

#pragma mark View drawing

- (void)viewWillAppear:(BOOL)animated {
simpleLayer_.backgroundColor = [[UIColor clearColor] CGColor];
simpleLayer_.bounds = CGRectMake(0.f, 0.f, 240.f, 90.f);
simpleLayer_.position = CGPointMake(160.f, 150.f);
simpleLayer_.contents = (id)[[UIImage imageNamed:@"FTSLogo.png"] CGImage];

moneyLayer_.backgroundColor = [[UIColor clearColor] CGColor];
moneyLayer_.bounds = CGRectMake(0.f, 0.f, 290.f, 125.f);
moneyLayer_.position = CGPointMake(160.f, 265.f);
moneyLayer_.delegate = self;
[moneyLayer_ setValue:[NSNumber numberWithBool:YES] forKey:@"moneyImageIsBen"];
[moneyLayer_ setNeedsDisplay];
}

- (void)viewWillDisappear:(BOOL)animated {
moneyLayer_.delegate = nil;
}

- (void)displayLayer:(CALayer *)layer {
if(layer == moneyLayer_) {
if([[layer valueForKey:@"moneyImageIsBen"] boolValue]) {
layer.contents = (id)[[UIImage imageNamed:@"Ben.png"] CGImage];
} else {
layer.contents = (id)[[UIImage imageNamed:@"Steve.png"] CGImage];
}
}
}

#pragma mark Event Handlers

- (void)toggleMoney:(id)sender {
BOOL isBen = [[moneyLayer_ valueForKey:@"moneyImageIsBen"] boolValue];
[moneyLayer_ setValue:[NSNumber numberWithBool:!isBen] forKey:@"moneyImageIsBen"];
[moneyLayer_ setNeedsDisplay];
}

@end
2 changes: 1 addition & 1 deletion Classes/Samples/LayerDrawing.h
Expand Up @@ -26,7 +26,7 @@


@interface LayerDrawing : UIViewController {

CALayer *drawingLayer_;
}

@end

0 comments on commit 0e4e41f

Please sign in to comment.