CABasicAnimation not animating on CAShapeLayer

Core Animation documentation seems simple enough, yet I can't figure out what's missing. I have a CAShapeLayer that I would like to animate using a simple CABasicAnimation.

I build the CAShapeLayer like so:

{
 CGRect rect = CGRectMake(focal.x, focal.y, (self.radius * 2), (self.radius * 2));

 self.touchCircle = [CAShapeLayer layer];
 [self.touchCircle setPath:[[UIBezierPath bezierPathWithOvalInRect:rect] CGPath]];
 [self.touchCircle setFrame:rect];
 [self.touchCircle setLineWidth:self.stroke];
 [self.touchCircle setPosition:focal];

 [self focalColorOfPoint:focal];

 [self.layer addSublayer:self.touchCircle];
}

and attempt an animation:

CABasicAnimation *radiusScale = [CABasicAnimation animationWithKeyPath:@"size"];

[radiusScale setFromValue:[NSValue valueWithCGSize:CGSizeMake(self.mRadius, self.mRadius)]];
[radiusScale setToValue:[NSValue valueWithCGSize:CGSizeMake(self.radius, self.radius)]];
[radiusScale setDuration:0.3f];

[self.touchCircle addAnimation:radiusScale forKey:@"touchCircleRadiusScaleUp"];

Any suggestions? Thanks in advance!


尝试使用animationWithKeyPath:@“transform”和动画

.toValue=[NSValue valueWithCATransform3D:CATransform3DMakeScale(scaleX, scaleY, scaleZ)];
链接地址: http://www.djcxy.com/p/74258.html

上一篇: 如何旋转一个圆形的CAShapeLayer弧?

下一篇: CABasicAnimation不在CAShapeLayer上生成动画