【问题标题】:CABasicAnimation not animating on CAShapeLayerCABasicAnimation 不在 CAShapeLayer 上制作动画
【发布时间】:2014-07-22 19:51:23
【问题描述】:

核心动画文档看起来很简单,但我不知道缺少什么。我有一个 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"];

有什么建议吗?提前致谢!

【问题讨论】:

标签: ios objective-c core-graphics core-animation


【解决方案1】:

尝试使用animationWithKeyPath:@"transform" 和动画

.toValue=[NSValue valueWithCATransform3D:CATransform3DMakeScale(scaleX, scaleY, scaleZ)];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-01
    相关资源
    最近更新 更多