我有一个倒抛物线,我需要有一个视图遍历parabola.The视图的路径,应该沿着抛物线的路径稍微旋转和平移。
我做了一些研究,发现BezierPath (带控制点的四曲线)可以用来绘制抛物线的路径,然后我们可以使用CAKeyFramAnimation沿path.Animating移动对象,沿抛物线路径的视图对象使我感到困惑。如何在抛物线内不断更改对象的起始点,并保持视图的最新状态?
下面是我想用抛物线图实现的简短描述
视图从抛物线中的一个特定点开始,然后遍历抛物线直到指定的端点。,我如何找到抛物线内的端点?,当视图到达它的结束时,它可以从那个点开始下一个遍历,然后移动到parabola.This中的任何其他点,在下一个端点上连续发生。
这是一个粗略的草图,哦,路径和视图会是怎样的呢?

同时,我也希望通过路径的视图的旋转和平移同时发生。
这是如何做到的呢?
谢谢!
发布于 2013-08-18 17:53:16
看下面的源代码,
画抛物线
CGMutablePathRef path = CGPathCreateMutable();
CGPathMoveToPoint(path,NULL,50.0,120.0);
CGPathAddCurveToPoint(path,NULL,50.0,275.0,
150.0,275.0,
150.0,120.0);
CGPathAddCurveToPoint(path,NULL,150.0,275.0,
250.0,275.0,
250.0,120.0);
CGPathAddCurveToPoint(path,NULL,250.0,275.0,
350.0,275.0,
350.0,120.0);
CGPathAddCurveToPoint(path,NULL,350.0,275.0,
450.0,275.0,
450.0,120.0);沿着一条小路走CAKeyFrameAnimation。
CAKeyframeAnimation* AniLoc = [CAKeyframeAnimation animationWithKeyPath:@"position"]; // notice key change
// rest is the same
AniLoc.path = thePath;
AniLoc.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
AniLoc.keyTimes= [NSArray arrayWithObjects:[NSNumber numberWithFloat:0.0f],
[NSNumber numberWithFloat:0.3f],
[NSNumber numberWithFloat:1.0f],nil];
AniLoc.duration = 2.0;
CFRelease(thePath);
[self.logo.layer addAnimation:AniLoc forKey:nil];https://stackoverflow.com/questions/18300478
复制相似问题