简体   繁体   中英

UIView CATransform3DMakeRotation horizontally from left to right

I am trying to rotate my view horizontally from left to right. So I am using CATransform3DMakeRotation to do rotation.

Here is my 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];

This code really works, But it rotates my view half only.. I want to make full rotation. So i changed the value M_PI/2 into M_PI , like this

CATransform3DMakeRotation(M_PI,0,1.0,0.0);

But for this value, my view is not rotating at all. Please give me some suggestion.

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 is Your view outlet so don't forget to IBOutlet it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM