iPhone dev - 手动旋转视图 [英] iPhone dev - Manually rotate view

查看:26
本文介绍了iPhone dev - 手动旋转视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 autoresizingMasks 手动旋转视图,就好像用户旋转了手机并且它已经自动旋转了一样.我也希望它是即时的,没有动画.我你想知道我为什么需要这个,看看我的另一个问题 iPhone Dev - 保持界面旋转.

How can I manually rotate a view using the autoresizingMasks, as if the user had rotated the phone and it had auto-rotated. Also I want it to be instant, no animation. I you want to know why I need this, look at my other question at iPhone Dev - keeping interface rotation.

谢谢!!

推荐答案

你想要做的是使用仿射变换来旋转你的视图,虽然我现在没有代码在我面前,但我已经做到了.如果你做一个简单的旋转,你会发现你的视图会被切断,而不是像你想要的那样在中心,你需要在这里做的是设置你的图层的锚点(玩弄这个值直到你得到你想要的)为了使视图出现在您想要的位置.解决这个问题的方法是进行 90 度仿射变换旋转并查看它对视图的影响.通过这种方式,您应该能够确定图层锚点需要在哪里.稍后当我在我的 Mac 面前时,我会在这里发布一些示例代码.希望对你有帮助

What you want to do here is use Affine transforms to rotate your View, I have accomplished this though i dont have the code infront of me at the moment. If you do a simple rotation youll find that your view will be cut off and not in the center like youd want, what you need to do here is set the anchor of your layer (play around with the value till you get what you want) in order for the view to appear where you want it. The way to approach this is just do the 90 degree affine transform rotation and see the effects it has on the view. This way you should be able to figure out where you layers anchor needs to be. Ill post some sample code here later when I am infront of my mac. Hope it helps

这篇关于iPhone dev - 手动旋转视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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