2012-05-18 3 views
0

J'essaie de faire pivoter horizontalement ma vue de gauche à droite. Donc j'utilise CATransform3DMakeRotation pour faire la rotation.UIView CATransform3DMakeRotation horizontalement de gauche à droite

Voici mon code,

[UIView beginAnimations:nil context:nil]; 

[UIView setAnimationDuration:1]; 

[UIView setAnimationDelay:0]; 
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn]; 

newView.layer.transform = CATransform3DMakeRotation(M_PI/2,0,1.0,0.0); 
[UIView commitAnimations]; 

Ce code fonctionne vraiment, mais il tourne mon point de vue la moitié seulement .. Je veux faire une rotation complète. donc j'ai changé la valeur M_PI/2 dans M_PI, comme celui-ci

CATransform3DMakeRotation(M_PI,0,1.0,0.0); 

Mais pour cette valeur, mon point de vue ne tourne pas du tout. S'il vous plaît donnez-moi quelques suggestions.

+0

Tout va bien, il devrait fonctionner avec: 'CATransform3DMakeRotation (M_PI, 0.0,1.0,0.0);'. J'ai testé votre code et ça fonctionne bien. –

+0

Mais pour moi ça ne marche pas .. Tu es sûr, ça marche pour toi .. Peux-tu me dire si la vue tourne de droite à gauche ou de gauche à droite? –

+0

pouvez-vous pls télécharger votre échantillon .. Alors que je peux vérifier .. –

Répondre

0
UIImageView *imageView = [[[UIImageView alloc] init] autorelease]; // Don't forget to release this! I added autorelease. 
imageView.image = [UIImage imageNamed:@"photo1.png"]; 
imageView.frame = CGRectMake(0, 0, viewOutlet.frame.size.width, viewOutlet.frame.size.height); 

[viewOutlet addSubview:imageView]; 

[UIView beginAnimations:nil context:nil]; 
[UIView setAnimationDuration:1]; 
[UIView setAnimationDelay:0]; 


[UIView setAnimationCurve:UIViewAnimationCurveEaseIn]; 
viewOutlet.layer.anchorPoint = CGPointMake(0.0f, 0.5f); 
viewOutlet.layer.transform =CATransform3DMakeRotation(M_PI,0,1.0,0.0); 
[UIView commitAnimations]; 

** viewOutlet est votre point de vue il ne faut pas oublier de IBOutlet il.

+0

Non, je ne veux pas ça .. Mais je l'ai eu .. Voici le code .. [UIView beginAnimations: nil context: nil]; \t \t \t \t [UIView setAnimationDuration: 1]; \t \t \t \t [UIView setAnimationDelay: 0]; \t \t [UIView setAnimationCurve: UIViewAnimationCurveEaseIn]; \t \t \t \t newView.layer.anchorPoint = CGPointMake (0.0f, 0.5f); \t \t newView.layer.transform = CATransform3DMakeRotation (M_PI, 0,1.0,0.0); \t \t [UIView commitAnimations]; Vraiment merci pour votre aide :) –

+0

Vous êtes les bienvenus :) –

+0

Encore une fois j'ai eu un problème avec la même chose .. Whn j'utilise ce code pour le fond uni ou un simple, il fonctionne génial .. Mais quand je l'essaye avec une autre vue qui en tant qu'image image en arrière-plan, la rotation de droite à gauche ne se passe pas .. Pls me sortir de cela .. Voici mon code .. –

Questions connexes