o Updated RMCircle to use setPosition:animated:
Showing
1 changed file
with
14 additions
and
14 deletions
@@ -35,7 +35,7 @@ | @@ -35,7 +35,7 @@ | ||
35 | 35 | ||
36 | @interface RMCircle () | 36 | @interface RMCircle () |
37 | 37 | ||
38 | -- (void)updateCirclePath; | 38 | +- (void)updateCirclePathAnimated:(BOOL)animated; |
39 | 39 | ||
40 | @end | 40 | @end |
41 | 41 | ||
@@ -68,7 +68,7 @@ | @@ -68,7 +68,7 @@ | ||
68 | enableDragging = YES; | 68 | enableDragging = YES; |
69 | 69 | ||
70 | circlePath = NULL; | 70 | circlePath = NULL; |
71 | - [self updateCirclePath]; | 71 | + [self updateCirclePathAnimated:NO]; |
72 | 72 | ||
73 | return self; | 73 | return self; |
74 | } | 74 | } |
@@ -85,7 +85,7 @@ | @@ -85,7 +85,7 @@ | ||
85 | 85 | ||
86 | #pragma mark - | 86 | #pragma mark - |
87 | 87 | ||
88 | -- (void)updateCirclePath | 88 | +- (void)updateCirclePathAnimated:(BOOL)animated |
89 | { | 89 | { |
90 | CGPathRelease(circlePath); circlePath = NULL; | 90 | CGPathRelease(circlePath); circlePath = NULL; |
91 | 91 | ||
@@ -102,7 +102,7 @@ | @@ -102,7 +102,7 @@ | ||
102 | 102 | ||
103 | CGFloat offset = floorf(-lineWidthInPixels / 2.0f) - 2; | 103 | CGFloat offset = floorf(-lineWidthInPixels / 2.0f) - 2; |
104 | CGRect newBoundsRect = CGRectInset(rectangle, offset, offset); | 104 | CGRect newBoundsRect = CGRectInset(rectangle, offset, offset); |
105 | - | 105 | + |
106 | [self setBounds:newBoundsRect]; | 106 | [self setBounds:newBoundsRect]; |
107 | 107 | ||
108 | // DLog(@"Circle Rectangle: %f, %f, %f, %f", rectangle.origin.x, rectangle.origin.y, rectangle.size.width, rectangle.size.height); | 108 | // DLog(@"Circle Rectangle: %f, %f, %f, %f", rectangle.origin.x, rectangle.origin.y, rectangle.size.width, rectangle.size.height); |
@@ -113,14 +113,14 @@ | @@ -113,14 +113,14 @@ | ||
113 | 113 | ||
114 | // animate the path change if we're in an animation block | 114 | // animate the path change if we're in an animation block |
115 | // | 115 | // |
116 | - if ([CATransaction animationDuration] > 0) | 116 | + if (animated) |
117 | { | 117 | { |
118 | CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"path"]; | 118 | CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"path"]; |
119 | - | 119 | + |
120 | pathAnimation.duration = [CATransaction animationDuration]; | 120 | pathAnimation.duration = [CATransaction animationDuration]; |
121 | pathAnimation.fromValue = [NSValue valueWithPointer:self.shapeLayer.path]; | 121 | pathAnimation.fromValue = [NSValue valueWithPointer:self.shapeLayer.path]; |
122 | pathAnimation.toValue = [NSValue valueWithPointer:newPath]; | 122 | pathAnimation.toValue = [NSValue valueWithPointer:newPath]; |
123 | - | 123 | + |
124 | [self.shapeLayer addAnimation:pathAnimation forKey:@"animatePath"]; | 124 | [self.shapeLayer addAnimation:pathAnimation forKey:@"animatePath"]; |
125 | } | 125 | } |
126 | 126 | ||
@@ -138,7 +138,7 @@ | @@ -138,7 +138,7 @@ | ||
138 | { | 138 | { |
139 | [lineColor release]; | 139 | [lineColor release]; |
140 | lineColor = [newLineColor retain]; | 140 | lineColor = [newLineColor retain]; |
141 | - [self updateCirclePath]; | 141 | + [self updateCirclePathAnimated:NO]; |
142 | } | 142 | } |
143 | } | 143 | } |
144 | 144 | ||
@@ -148,27 +148,27 @@ | @@ -148,27 +148,27 @@ | ||
148 | { | 148 | { |
149 | [fillColor release]; | 149 | [fillColor release]; |
150 | fillColor = [newFillColor retain]; | 150 | fillColor = [newFillColor retain]; |
151 | - [self updateCirclePath]; | 151 | + [self updateCirclePathAnimated:NO]; |
152 | } | 152 | } |
153 | } | 153 | } |
154 | 154 | ||
155 | - (void)setRadiusInMeters:(CGFloat)newRadiusInMeters | 155 | - (void)setRadiusInMeters:(CGFloat)newRadiusInMeters |
156 | { | 156 | { |
157 | radiusInMeters = newRadiusInMeters; | 157 | radiusInMeters = newRadiusInMeters; |
158 | - [self updateCirclePath]; | 158 | + [self updateCirclePathAnimated:NO]; |
159 | } | 159 | } |
160 | 160 | ||
161 | - (void)setLineWidthInPixels:(CGFloat)newLineWidthInPixels | 161 | - (void)setLineWidthInPixels:(CGFloat)newLineWidthInPixels |
162 | { | 162 | { |
163 | lineWidthInPixels = newLineWidthInPixels; | 163 | lineWidthInPixels = newLineWidthInPixels; |
164 | - [self updateCirclePath]; | 164 | + [self updateCirclePathAnimated:NO]; |
165 | } | 165 | } |
166 | 166 | ||
167 | -- (void)setPosition:(CGPoint)position | 167 | +- (void)setPosition:(CGPoint)position animated:(BOOL)animated |
168 | { | 168 | { |
169 | - [super setPosition:position]; | 169 | + [self setPosition:position]; |
170 | 170 | ||
171 | - [self updateCirclePath]; | 171 | + [self updateCirclePathAnimated:animated]; |
172 | } | 172 | } |
173 | 173 | ||
174 | @end | 174 | @end |
-
Please register or login to post a comment