我正在做一些使用塊級技術的動畫。我想根據一定的條件停止動畫。我將如何阻止動畫完成?如何停止正在運行的動畫
以下是我的動畫代碼:
[UIView animateWithDuration:2.0 delay:0.0 options:UIViewAnimationOptionAllowUserInteraction
animations:^{
if([arrAns count]>0)
vwb1.center = CGPointMake(260, 40);
}
completion:^(BOOL finished){
[UIView animateWithDuration:1.5 delay:0.0 options:UIViewAnimationOptionAllowUserInteraction
animations:^{
if([arrAns count]>1)
vwb2.center = CGPointMake(260, 100);
}
completion:^(BOOL finished){
[UIView animateWithDuration:1.0 delay:0.0 options:UIViewAnimationOptionAllowUserInteraction
animations:^{
if([arrAns count]>2)
vwb3.center = CGPointMake(260, 160);
}
completion:^(BOOL finished){
[UIView animateWithDuration:1.0 delay:0.0 options:UIViewAnimationOptionAllowUserInteraction
animations:^{
if([arrAns count]>3)
vwb4.center = CGPointMake(260, 220);
}
completion:^(BOOL finished){
[UIView animateWithDuration:1.0 delay:0.0 options:UIViewAnimationOptionAllowUserInteraction animations:^{
if([arrAns count]>4)
vwb5.center = CGPointMake(260, 280);
} completion:nil];
}];
}];
}
];
}];
我沒有任何這裏的關鍵,所以我可以n不是將其刪除一個關鍵的基礎上。還有一個功能是removeallanimation,但我無法使用它。如果有人能夠幫助我如何使用它,它也會很好。
編輯:好吧,我想通了,如何做到這一點,我使用下面的代碼做它:
[self.view.layer removeAllAnimations];
但現在我有問題尚未開始了我的塊級動畫仍在運行。所以如果我在第二個塊中刪除動畫,它仍然會執行剩餘的塊。我也需要阻止它。
感謝
潘卡
你試過removeallanimations? –
@Praveen現在請檢查我的信息。我有更新... – pankaj
你必須單獨停止所有圖層的動畫。 –