2010-10-11 3 views
1

У меня есть 5 различных анимаций, которые оживляют, затем исчезают один за другим. Есть ли способ поставить их на бесконечный цикл, так что анимация №1 начинается и заканчивается, затем начинается анимация №2 и заканчивается и т. Д.? весь процесс затем повторяется в бесконечном цикле.анимации на бесконечном цикле

У меня есть анимации в отдельных блоках на задержках. Я предполагаю, что есть лучший способ сделать это. это то, что у меня есть на данный момент:

-(void) firstAnimation { 

     [UIView beginAnimations:@"Fade Out Image" context:nil]; 
     [UIView setAnimationDelegate:self]; 
     [UIView setAnimationDelay:40]; 
     [UIView setAnimationRepeatCount:30]; 
     [UIView setAnimationRepeatAutoreverses:YES]; 
     [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 
     theImage.alpha = 1; 
     theImage.alpha = 0.1; 

     [UIView commitAnimations]; 

     [self secondAnimation]; 

} 

-(void) secondAnimation { 

     tapImage2.hidden = NO; 

     [UIView beginAnimations:@"Fade Out Image" context:nil]; 
     [UIView setAnimationDelegate:self]; 
     [UIView setAnimationDelay:53]; 
     [UIView setAnimationRepeatCount:29]; 
     [UIView setAnimationRepeatAutoreverses:YES]; 
     [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 
     theImage2.alpha = 1; 
     theImage2.alpha = 0.1;  

     [UIView commitAnimations]; 

    [self thirdAnimation]; 

} 

это продолжается 5 анимаций. спасибо за любую помощь.

ответ

8

Вместо использования задержки установите делегат анимации и создайте способ анимации. Я заметил, что вы уже устанавливаете делегат.

[UIView setAnimationDelegate:self]; 
[UIView setAnimationDidStopSelector:@selector(animationFinished:finished:context:)]; 

- (void)animationFinished:(NSString *)animationID finished:(BOOL)finished context:(void *)context { 
    //Start next animation based on the animationID of the last one... 
} 
+0

спасибо. это гораздо лучший подход. – hanumanDev

Смежные вопросы