2009-10-10 6 views

Répondre

0

Vous voudrez utiliser CoreAnimation pour cela; fondamentalement, vous devrez appliquer une animation à la propriété transform de votre vue d'image. Il y a beaucoup de samples sur la page de développeur d'Apple qui montrent des variations à ce sujet.

4
#import <QuartzCore/QuartzCore.h> 

[UIView beginAnimations:@"RotationAnimation" context:nil]; 

CABasicAnimation *fullRotationAnimation; 
fullRotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"]; 
fullRotationAnimation .fromValue = [NSNumber numberWithFloat:0]; 
fullRotationAnimation.toValue = [NSNumber numberWithFloat:((360*M_PI)/180)]; 
fullRotationAnimation.duration = 2;   // speed for the rotation. Smaller number is faster 
fullRotationAnimation.repeatCount = 1e100f; // number of times to spin. 1 = once 
[myImage.layer addAnimation:fullRotationAnimation forKey:@"360"]; 

[UIView commitAnimations]; 
+2

En fait, je ne crois pas que le bloc d'animation begin/commit pour UIView soit nécessaire ici, car vous êtes en train d'animer explicitement le calque de la vue. Vous pouvez également utiliser "transform.rotation.z" en tant que mot de passe pour l'animation, afin de spécifier clairement l'axe sur lequel tourner. –

0

Cela peut être la réponse tardive à votre question, mais il vous aidera quelqu'un ..
En utilisant le CGAffineTransformMakeRotation nous pouvons en mesure de faire pivoter l'image

faire pivoter l'image dans le sens anti-horaire

-(void)rotate 
    { 
     x++; 
     CGAffineTransform transform = CGAffineTransformMakeRotation(x); 
     imageView.transform = transform; 
     [self performSelector:@selector(rotate) withObject:self afterDelay:0.1]; 

    } 

Pour ClockWise Direction utilisation X-;

Questions connexes