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]
时,动画也突然重新启动。
我很感激任何帮助。
你试过路过'UIViewAnimationOptionBeginFromCurrentState'呢? –
这似乎有点帮助与过渡的突然,谢谢。为了得到我以后的效果,我不得不改变代码,取消了添加另一个动画的'AutoReverse'。 – garethdn