2013-02-27 8 views
-2

La méthode setAnimationDuration n'a aucun effet sur mon code, My Animation est trop rapide. Voici le codepourquoi setAnimationDuration Aucun effet, mon animation est trop rapide

[UIView beginAnimations:nil context:nil];  
image1.frame=CGRectMake(0, 0, 0,image1.frame.size.height); 
image2.frame=CGRectMake(image2.frame.size.width, 0, 0,image2.frame.size.height); 
[UIView setAnimationDuration:10]; 
[UIView setAnimationDelegate:self]; 
[UIView commitAnimations]; 

Répondre

4

Vous devez définir la valeur de votre durée avant de modifier les propriétés animables .

[UIView beginAnimations:nil context:nil]; 
[UIView setAnimationDuration:10]; 
image1.frame=CGRectMake(0, 0, 0,image1.frame.size.height); 
image2.frame=CGRectMake(image2.frame.size.width, 0, 0,image2.frame.size.height); 
[UIView setAnimationDelegate:self]; 
[UIView commitAnimations]; 

La discussion au sein de référence de classe de pommes pour les Etats UIView pour la méthode setAnimationDuration:

Et vous devez appeler cette méthode avant de modifier les propriétés de votre point de vue animables. La valeur par défaut est 0,2 seconde.

C'est pourquoi vous obtenez des animations très rapides.

Ce style d'animation a été déconseillé à ios4, donc si ce qui précède ne fonctionne pas, essayez d'utiliser le nouveau style de blocs d'animation.

+0

merci, comme vous le dites, maintenant ça marche – Tung

0

Ajouter une animation à votre vue à l'aide:

[UIView animateWithDuration:2.0 animations:^() 
{ 
    //Your code here 
}]; 

Ou utiliser cette approche:

[UIView transitionWithView:super.view duration:1.0 options:UIViewAnimationOptionTransitionCurlUp animations:^ 
    { 
     //your code here 
    }completion:NULL 
    ]; 
Questions connexes