我正在尝试缩小循环现金帕特莱耶尔,但使用键路径'的路径'似乎不起作用。
CGPathRef startPath = [UIBezierPath bezierPathWithOvalInRect:startRect].CGPath;
CGPathRef endPath = [UIBezierPath bezierPathWithOvalInRect:CGRectInset(startRect, 15, 15)].CGPath;
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"path"];
animation.duration = 1.0;
animation.fromValue = (__bridge id)startPath;
animation.toValue = (__bridge id)endPath;
animation.autoreverses = YES;
animation.repeatCount = CGFLOAT_MAX;
animation.timingFunction = [CAMediaTimingFunction functionWithControlPoints:0.6 :0.3 :0.8 :0.45];
//circleLayer is a CAShapeLayer
[self.circleLayer addAnimation:animation forKey:@"pathAnimation"];
我认为我一定会误解路径动画的工作原理,因为如果我试图为不透明度或转换动画,几乎相同的代码似乎可以正常工作。
。有什么想法吗?
我最近也有相同的问题,最终通过创建圆圈,然后使刻度cgaffineTransform进行动画解决。在视图中,谁是圆圈,我只是使用
CGAffineTransform transform = CGAffineTransformIdentity;
transform = CGAffineTransformScale(transform, scaleX, scaleY);
[UIView animateWithDuration: 0.5 animations: ^{
self.transform = transform;
}];
希望这会有所帮助!