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