0

我正在尝试从左到右水平旋转我的视图。所以我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/2M_PI,像这样

CATransform3DMakeRotation(M_PI,0,1.0,0.0);

但是对于这个值,我的观点根本没有旋转。请给我一些建议。

4

1 回答 1

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 它。

于 2012-05-18T13:54:12.357 回答