プログラムの他の場所にBOOLを設定して、その無限ループの繰り返しをキャンセルすることを目的として、次のUIView animateWithDuration:
メソッドを設定しています。アニメーションのサイクルが終了するたびanimationOn
にブロックが呼び出されるという印象を受けましたが、そうではないようです。completion
ブロックがcompletion
繰り返しアニメーションで呼び出されたことはありますか?そうでない場合は、このメソッドの外部からこのアニメーションを停止する別の方法はありますか?
- (void) animateFirst: (UIButton *) button
{
button.transform = CGAffineTransformMakeScale(1.1, 1.1);
[UIView animateWithDuration: 0.4
delay: 0.0
options: UIViewAnimationOptionCurveEaseOut | UIViewAnimationOptionAutoreverse | UIViewAnimationOptionRepeat
animations: ^{
button.transform = CGAffineTransformIdentity;
} completion: ^(BOOL finished){
if (!animationOn) {
[UIView setAnimationRepeatCount: 0];
}
}];
}