1

誰かがアニメーションをループし、別のアニメーションでアニメーションを中断し、元のアニメーションを再開する正しい方法を教えてくれることを願っています. 私が現在アニメーションを設定している方法は次のとおりです。

-(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]とアニメーションも突然再開します。

助けていただければ幸いです。

4

1 に答える 1

0

アニメーションの一時停止と再開に関するこのQ&Aをご覧ください。これが役立つ場合があります:QA1673

于 2012-05-18T12:35:32.067 に答える