【发布时间】:2011-04-30 04:55:32
【问题描述】:
我想对图像使用动画,从单击按钮开始并在 5 秒后停止。我使用此代码。
-(IBAction) btnClicked
{
CABasicAnimation *fullRotation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
fullRotation.fromValue = [NSNumber numberWithFloat:0];
fullRotation.toValue = [NSNumber numberWithFloat:((360*M_PI)/180)];
fullRotation.duration = 6;
fullRotation.repeatCount = 1e100f;
fullRotation.delegate = self;
[imgView.layer addAnimation:fullRotation forKey:@"360"];
[imgView.layer setSpeed:3.0];
}
使用此代码动画已启动,但我不知道如何在 5 秒后停止此动画。
【问题讨论】:
-
转到此链接它有您完美的解决方案。 enter link description here
标签: iphone animation cabasicanimation