简体   繁体   English

如何平滑地将CAShapeLayer的路径动画化为另一个路径?

[英]How to animate a CAShapeLayer`s path to another path smoothly?

I have a CAShapeLayer with a specifical shape. 我有一个具有特定形状的CAShapeLayer And i want to change the path of the layer to animate its shape. 我想更改图层的路径以使其形状动起来。 But when i use CABasicAnimation , the animation is always not that good to match my requirement. 但是,当我使用CABasicAnimation ,动画总是不能很好地满足我的要求。

I try some different ways. 我尝试一些不同的方法。 I have the same number of points in two paths. 我在两条路径中的点数相同。 The points of the previous path does not go the place i want. 上一条路径的要点没有到达我想要的位置。 Some straight lines occurs. 出现一些直线。 I want to animate a cloud into a circle. 我想将云动画成一个圆圈。 Here is the images show the problem. 这是显示问题的图像。 在此处输入图片说明 在此处输入图片说明 在此处输入图片说明 Help 救命

You should give CAKeyframeAnimation with intermediate shapes a try. 您应该尝试一下具有中间形状的CAKeyframeAnimation I think the spike in the cloud is reason for the unexpected behaviour. 我认为云的高峰是意外行为的原因。 The intermediate shapes should transform the cloud to a convex and smooth shape (like a potato), and after that to a circle. 中间形状应将云转换为凸出且平滑的形状(如马铃薯),然后再转换为圆形。 I would try to move only the spike and its surrounding points first. 我将尝试首先仅移动峰值及其周围的点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM