iPhone上使用CAKeyFrameAnimation绘制路径

iPhone上使用CAKeyFrameAnimation绘制路径

本文介绍了在iPhone上使用CAKeyFrameAnimation绘制路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想逐渐绘制一条路径,即我希望路径看起来好像是手工绘制的。我设法创造了我需要的道路。我还设法创建了一个使用此路径的CAKeyFrameAnimation。但到目前为止,我只能沿着这条路径移动一个物体。我想在路径上移动一个对象(比如一支铅笔),并且路径看起来好像是绘制的。

I want to draw a path gradually, i.e. I want the path to appear as if it is drawn by hand. I have managed to create the path I need. I have also managed to create a CAKeyFrameAnimation that uses this path. But so far I can only move an object along this path. I would like to both move an object (say a pencil) along the path, and have the path appear as if it is drawn.

任何指针?

推荐答案

使用您的路径创建 CAShapeLayer 并为图层的<$设置动画c $ c> strokeEnd 从 0.0 1.0 。 (这是iOS SDK 4.2中的新功能,不适用于以前的版本。)

Create a CAShapeLayer with your path and animate the layer's strokeEnd from 0.0 to 1.0. (This is new in iOS SDK 4.2, won't work with previous versions.)

这篇关于在iPhone上使用CAKeyFrameAnimation绘制路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 09:32