使用CAKeyFrameAnimation将路径中的图像设置为指定位置的动画

时间:2013-07-24 11:48:01

标签: ios

我想要实现的是能够沿着路径在指定位置沿路径设置图像的动画和位置。路径上的百分比很好。

我想要实现的目标:

Current Location of Image Along the Path New position long the path

当我设置动画时,它会在整个路径上动画,回到起点。我需要知道如何在路径的任何地方指定一个停靠点。

片段如下:

imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"EMOTICON_0.png"]];
[view addSubview:imageView];

CAKeyframeAnimation *positionAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
positionAnimation.path = [view path].CGPath;
positionAnimation.rotationMode = kCAAnimationRotateAuto;
positionAnimation.removedOnCompletion = NO;
positionAnimation.fillMode = kCAFillModeForwards;
positionAnimation.duration = 5.0;
positionAnimation.timingFunction =  [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];


[imageView.layer addAnimation:positionAnimation forKey:positionAnimation.keyPath];

0 个答案:

没有答案