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