Skip to content

Commit

Permalink
Do not synthesize CALayer properties
Browse files Browse the repository at this point in the history
The CALayer class has automatic properties so we can just use @dynamic instead of @synthesize
See Rob Napier (@cocoaphony) Animating Custom Layer Properties talk at http://cocoaheads.tv/animating-custom-layer-properties-by-rob-napier/
  • Loading branch information
0xced committed Oct 22, 2012
1 parent 8eb2deb commit 92c2ec9
Showing 1 changed file with 5 additions and 19 deletions.
24 changes: 5 additions & 19 deletions DACircularProgress/DACircularProgressView.m
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -22,31 +22,17 @@ @interface DACircularProgressLayer : CALayer


@implementation DACircularProgressLayer @implementation DACircularProgressLayer


@synthesize trackTintColor = _trackTintColor; @dynamic trackTintColor;
@synthesize progressTintColor = _progressTintColor; @dynamic progressTintColor;
@synthesize roundedCorners = _roundedCorners; @dynamic roundedCorners;
@synthesize thicknessRatio = _thicknessRatio; @dynamic thicknessRatio;
@synthesize progress = _progress; @dynamic progress;


+ (BOOL)needsDisplayForKey:(NSString *)key + (BOOL)needsDisplayForKey:(NSString *)key
{ {
return [key isEqualToString:@"progress"] ? YES : [super needsDisplayForKey:key]; return [key isEqualToString:@"progress"] ? YES : [super needsDisplayForKey:key];
} }


- (id)initWithLayer:(DACircularProgressLayer *)layer
{
self = [super initWithLayer:layer];
if (self)
{
self.trackTintColor = layer.trackTintColor;
self.progressTintColor = layer.progressTintColor;
self.roundedCorners = layer.roundedCorners;
self.thicknessRatio = layer.thicknessRatio;
self.progress = layer.progress;
}
return self;
}

- (void)drawInContext:(CGContextRef)context - (void)drawInContext:(CGContextRef)context
{ {
CGRect rect = self.bounds; CGRect rect = self.bounds;
Expand Down

0 comments on commit 92c2ec9

Please sign in to comment.