iphone - 在 Cocoa Touch 中旋转 UIView

标签 iphone cocoa-touch uiview rotation

我见过其他人也提出过这个问题,但大多数回复都不适用于最新的 3.0 版 iPhone 操作系统。不管怎样,我想知道如何在没有来自加速度计的任何输入的情况下以编程方式旋转 UIView。到目前为止我找到的代码:

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

但是,这不适用于 UIView(在我的测试中)。我是否必须对 AppDelegate 执行某些操作才能使此/其他代码正常运行,或者是否有更好的方法来执行相同的操作?

感谢您的帮助!

最佳答案

这对我有用

 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;

关于iphone - 在 Cocoa Touch 中旋转 UIView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1350233/

相关文章:

iphone - MPMoviePlayer 跳到电影中的时间

iphone - 过期证书 iPhone "in house"企业部署

iPhone 编码 : How can I set a variable in a ViewController from another?

iphone - Apple 审查中的 iPad 应用程序崩溃 - 无法在模拟器中复制,有崩溃日志

iphone - 将 ipad 应用程序转换为在 iPhone 上运行(通用应用程序)

ios - 创建连续动画

objective-c - 如何使用performSelector :withObject:afterDelay: on a method with multiple arguments

ios - 如何获得底部y坐标

ios - 如何以编程方式更改 UIView 的 "origin"(如 Xcode 中的标记)?

iphone - UIView的setNeedsLayout、layoutIfNeeded和layoutSubviews之间有什么关系?