我希望有人可以告诉我循环动画的正确方法,用另一个动画中断动画,然后恢复原始动画。我目前设置动画的方式是这样的:
-(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]
时,动画也会突然重启。
我很感激任何帮助。