Iphone UIView CATTransferM3D从左向右水平旋转
我试图从左向右水平旋转我的视图。因此,我使用Iphone UIView CATTransferM3D从左向右水平旋转,iphone,objective-c,ios,Iphone,Objective C,Ios,我试图从左向右水平旋转我的视图。因此,我使用catTransferM3dMakeRotation进行旋转 这是我的密码 [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:1]; [UIView setAnimationDelay:0]; [UIView setAnimationCurve:UIViewAnimationCurveEaseIn]; newView.layer.transform = C
catTransferM3dMakeRotation
进行旋转
这是我的密码
[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);
但对于这个值,我的观点根本不是旋转的。请给我一些建议
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是您的视图出口,因此不要忘了将其导出。一切正常,它应该可以使用:
CATTransferorM3dMakeRotation(M_PI,0.0,1.0,0.0)代码>。我已经测试了你的代码,它运行得很好。但是对我来说它不工作。。你确定吗,他在为你工作。。你能告诉我视图是从右向左还是从左向右旋转吗?你能上传你的样本吗。。这样我就可以检查了,它是从左向右旋转的。好的,我会上传给你的样品,希望对你有所帮助。不,我不想那样。。但我明白了。。这是密码。。[UIView beginAnimations:nil上下文:nil];[UIView setAnimationDuration:1];[UIView setAnimationDelay:0];[UIView设置动画曲线:UIViewAnimationCurveEaseIn];newView.layer.anchorPoint=CGPointMake(0.0f,0.5f);newView.layer.transform=CATTransformerM3dMakeRotation(M_PI,0,1.0,0.0);[UIView委员会];真的非常感谢你的帮助:)同样的事情我也遇到了问题。。为什么我用这段代码作为简单的背景或者简单的工作呢。。但是当我尝试用其他视图作为背景时,从右到左的旋转并没有发生。。请把我弄出去。。这是我的代码..newView=[[UIView alloc]init];newView.frame=CGRectMake(189,0389,self.view.frame.size.height);imageView=[[UIImageView alloc]init];imageView.image=[UIImage ImageName:@“photo1.png”];imageView.frame=CGRectMake(0,0,newView.frame.size.width,newView.frame.size.height);[newView addSubview:imageView];[UIView beginAnimations:nil上下文:nil];[UIView setAnimationDuration:1];[UIView setAnimationDelay:0];[UIView设置动画曲线:UIViewAnimationCurveEaseIn];newView.layer.anchorPoint=CGPointMake(0.0f,0.5f);newView.layer.transform=CATTransformerM3dMakeRotation(M_PI,0,1.0,0.0);[UIView委员会]@用户1402675:为什么你要按程序做每件事?在Interface builder中创建UIView
(或者使用我的示例“viewOutlet”中已经用到的方法)。用outlet替换您创建的视图,它将正常工作。(将imageView作为子视图添加到此视图)。您的代码应该与我更新的答案中的代码类似。请查看。