核心动画文档似乎很简单,但我无法弄清楚缺少什么。我有一个CAShapeLayer,我想用简单的CABasicAnimation动画。
我像这样构建CAShapeLayer:
{
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];
}
并尝试动画:
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"];
有什么建议吗?提前谢谢!
答案 0 :(得分:1)
尝试使用animationWithKeyPath:@“transform”和动画
.toValue=[NSValue valueWithCATransform3D:CATransform3DMakeScale(scaleX, scaleY, scaleZ)];