2010-03-31 15 views
1

En essayant d'ajouter une animation à un UIImageView, mais il échoue toujours. Pourquoi? Voici le code:Pourquoi ne puis-je pas ajouter une animation à un UIImageView?

 //(…) 
     UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();  
     animationImage = [[UIImageView alloc]initWithImage:newImage]; 
     [self.view addSubview:animationImage]; 

     CATransition *animation = [CATransition animation]; 
     [animation setDelegate:self]; 
     [animation setDuration:0.35]; 
     [animation setTimingFunction:UIViewAnimationCurveEaseInOut]; 
     animation.type = @"pageCurl"; 
     animation.fillMode = kCAFillModeForwards; 
     animation.endProgress = 0.58; 
     [animation setRemovedOnCompletion:NO]; 
     [[animationImage layer] addAnimation:animation forKey:@"pageCurlAnimation"]; 

Répondre

2

Essayez d'utiliser:

[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]]; 

insteaad de:

[animation setTimingFunction:UIViewAnimationCurveEaseInOut]; 
+0

travail doens't. Ce qui est étrange, c'est que mon code fonctionne avec la couche self.view, mais pas avec la couche animationImage ... – Flocked

+0

Il me manque quelque chose, car UIImageView hérite de UIView, donc vous devriez être capable d'ajouter des animations à sa couche. – glorifiedHacker

+0

@Flocked: chère, essayez 'animationImage.layer' et acceptez cette réponse car elle m'a aidé aussi .. :) – rptwsthi