誰かがアニメーションをループし、別のアニメーションでアニメーションを中断し、元のアニメーションを再開する正しい方法を教えてくれることを願っています. 私が現在アニメーションを設定している方法は次のとおりです。
-(void) firstAnimation
{
[UIView animateWithDuration:1.0f delay:0 options:(UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse | UIViewAnimationOptionAllowUserInteraction) animations:^{
CGPoint bottomPoint = CGPointMake(215.0, 380.0);
imgBee.center = bottomPoint;
} completion:^(BOOL finished) {
}];
}
そして割り込み:
-(void) interruptAnimation
{
CGPoint point1 = CGPointMake(500, 500);
CGPoint originalCenter = CGPointMake(215.0, 410.0);
[UIView animateWithDuration:2.0f delay:0 options:(UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionAutoreverse) animations:^{
imgBee.center = point1;
} completion:^(BOOL finished) {
imgBee.center = originalCenter;
[self firstAnimation];
}];
}
これが最善の方法ではないことは確かです。元のアニメーションを中断するとinterruptAnimation
突然開始し、呼び出す[self firstAnimation]
とアニメーションも突然再開します。
助けていただければ幸いです。