我想知道如何設置動畫重複。重複次數需要由一個變量決定。在以下代碼中,變量int newPage
應確定動畫重複的頻率。重複動畫不定次數
我想這一點,但動畫(它採用了塊動畫)只執行一次:
for (int temp = 1; temp <= newPage; temp++) {
[self animatePage];
}
如果我將以下代碼,它就像我希望它,但這是硬編碼(即動畫將重複兩次),我看不出如何改變多久這個動畫代碼,根據我的變量NEWPAGE執行和數量的方式:
[UIView animateWithDuration:0
delay:0.1
options:UIViewAnimationOptionCurveEaseIn
animations:^{[self animatePage];}
completion:^(BOOL finished){[self animatePage];}];
,我會非常感激爲如何重複相同的動畫而不必硬編碼的建議我希望這個動畫重複的次數。
編輯:
我試圖執行下面的代碼,但只有一個動畫將實際進行:
[UIView animateWithDuration:0
delay:1
options:UIViewAnimationOptionCurveEaseIn
animations:^{
[UIView setAnimationRepeatCount:2];
[self animatePage];
}
completion:nil];
你知道,我相當肯定「removeAllAnimations」就是你在這裏之後 - 看下面的答案,歡呼! – Fattie 2014-03-07 16:24:58