Note that there are some explanatory texts on larger screens.

plurals
  1. POAnimating a CAShapeLayer while moving its parent UIView via the center property
    primarykey
    data
    text
    <p><strong>Update:</strong> </p> <p>There is no problem here. Turns out I was re-adding the animation every time I moved the point. Was else where in the code and I just totally glossed over it. Please ignore this question.</p> <p><strong>end update</strong></p> <p>I have a UIView which is just acting as a container for a UIImageView and a CAShaperLayer. The shape layer is drawing a circle and I have added a path animation to that shape layer to make it pulse. I want to be able to pulse the circle and move the container view at the same time using the center property of the UIView. However, when I set the center property on the container UIView, the pulse animation restarts from it's beginning no matter where it is at in it's animation. </p> <p>How do I prevent the pulse animation from restarting?</p> <p>Pulse animation:</p> <pre><code>CGRect startRect = CGRectMake(-10 + (self.bounds.size.width / 2), -10 + (self.bounds.size.height / 2), 20, 20); CGMutablePathRef fromPath = CGPathCreateMutable(); CGPathAddEllipseInRect(fromPath, NULL, startRect); CGRect endRect = CGRectMake(-20 + (self.bounds.size.width / 2), -20 + (self.bounds.size.height / 2), 40, 40); CGMutablePathRef toPath = CGPathCreateMutable(); CGPathAddEllipseInRect(toPath, NULL, endRect); CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"path"]; animation.fromValue = (id)fromPath; animation.toValue = (id)toPath; CGPathRelease(fromPath); CGPathRelease(toPath); animation.duration = 2.0f; animation.repeatCount = HUGE_VALF; [self.myCircleLayer addAnimation:animation forKey:self.pathAnimationKey]; </code></pre> <p>I move the container view by doing:</p> <pre><code>self.myContainerView.center = newPoint; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload