如何使用CAKeyFrameAnimation为圆形图像设置动画

时间:2013-06-19 12:48:24

标签: ios objective-c xcode4.5 quartz-core

我是ios开发的新手。 我正在实施一个Animation项目,我有一个circle.png图片。

如何在该图像上使用CAKeyFrameAnimation旋转图像?

1 个答案:

答案 0 :(得分:0)

代码: -

-(void)spinAnimation
{

    CABasicAnimation *rotation;
    rotation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
    rotation.fromValue = [NSNumber numberWithFloat:0];
    rotation.toValue = [NSNumber numberWithFloat:((360*M_PI)/180)];
    rotation.duration = 1.1; // Speed
    rotation.repeatCount = HUGE_VALF; // Repeat forever. Can be a finite number.
    [yourimageview.layer addAnimation:rotation forKey:@"Spin"];

}

希望它有所帮助。

相关问题