在Cocoa Touch中旋转UIView [英] Rotate UIView in Cocoa Touch

查看:111
本文介绍了在Cocoa Touch中旋转UIView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看过其他人有这个问题,但大多数的回应是不是在最新的3.0版本的iPhone操作系统。无论如何,我想知道如何我可以编程旋转UIView没有来自加速度计的任何输入。我到目前为止发现的代码:

I have seen other people who have had this question, but most of the responses aren't working on the latest 3.0 build of iPhone OS. Anyway, I'm wondering how I can programatically rotate a UIView without any input from the accelerometer. The code I have found so far:

CGAffineTransform transform = CGAffineTransformMakeRotation(3.14159/2);
view.transform = transform;
CGRect contentRect = CGRectMake(-80, 80, 480, 320);
view.bounds = contentRect;

然而,这不适用于UIView有没有什么我必须做我的AppDelegate为了这个/其他代码的功能,或者有更好的方法做同样的事情?

However, this doesn't work for UIView (in my testing). Is there something I have to do my AppDelegate in order for this/other code to function, or is there a better way of doing the same thing?

感谢任何帮助!

推荐答案

这适用于我

 CGAffineTransform transform = CGAffineTransformMakeRotation(M_PI_2);
 self.view.transform = transform;

 // Repositions and resizes the view.
 CGRect contentRect = CGRectMake(0,0, 480, 320);
 self.view.bounds = contentRect;

这篇关于在Cocoa Touch中旋转UIView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆