我正在尝试从左到右水平旋转视图。所以我使用CATransform3DMakeRotation
进行轮换。
这是我的代码,
[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];
这段代码确实有效,但它只旋转了我的视图一半..我想完全旋转。
所以我将值M_PI/2
更改为M_PI
,就像这样
CATransform3DMakeRotation(M_PI,0,1.0,0.0);
但是对于这个值,我的观点根本不是旋转。请给我一些建议。
答案 0 :(得分: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 是您的观看点,所以不要忘记IBOutlet。