iPhone dev - Manually rotate view(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 - 手动旋转视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:iPhone dev - 手动旋转视图


基础教程推荐
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01