画像にアニメーションを使用し、ボタンをクリックして開始し、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秒後にこのアニメーションを停止する方法がわかりません。