[英]How to abruptly end an animation?
我正在制作一個游戲,其中當用戶進行移動時,動畫中的源方和目標方會亮起。動畫持續時間為1秒。
問題是,當用戶太快地點擊前進按鈕時,所有源方和目標方方格都會亮起,導致由於第一個動畫在第一個結束之前就開始播放第二個動畫而導致出現許多亮起方格。
當動畫的持續時間還沒有結束時,我該如何突然結束動畫。
動畫功能代碼:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:value];
[UIView setAnimationRepeatCount:1];
// [UIView setAnimationRepeatAutoreverses:YES];
[self.view viewWithTag:(src+1)+2000].backgroundColor=[UIColor orangeColor];
[self.view viewWithTag:(src+1)+2000].backgroundColor=[UIColor clearColor];
[self.view viewWithTag:(dest+1)+2000].backgroundColor=[UIColor orangeColor];
[self.view viewWithTag:(dest+1)+2000].backgroundColor=[UIColor clearColor];
[UIView commitAnimations];
注意:-我接受不贊成投票是一種健康的批評方式,但是請寫出理由以便我可以改善
采用
#import <QuartzCore/QuartzCore.h>
.......
[myView.layer removeAllAnimations];
希望能幫助到你。 快樂的編碼:)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.