按比例缩放整个 UIView
我有一个基本的 UIView,当它水平时它占据整个 iPhone 屏幕。当设备旋转为纵向时,我希望视图基本上只是将其本身和其中的所有内容缩小到 2/3 大小,并将其置于屏幕中央,以便显示所有内容:
Image: http://img25.imageshack.us/img25/3281/rotateqx.jpg
我不能为不过我明白了。我搞乱了自动调整大小,但这似乎只有在我为每个子视图执行此操作时才有效,即使它可以正常缩放,但因为并非所有元素都居中,所以它们最终不会在纵向模式下位于正确的位置。
至于设置 UIViewContentMode,我可以让它对单个元素很好地工作,但不适用于整个视图,而且因为我正在实现自定义的绘图方法,所以我不能只为所有元素设置它单独。此外,谁的安置问题再次生效。
谢谢。
I have a base UIView which takes up the entire iPhone screen when the it is horizontal. When the device is rotated to portrait, I want the view to basically just scale down itself and everything in it to 2/3 the size and center it on the screen so everything is shown:
Image: http://img25.imageshack.us/img25/3281/rotateqx.jpg
I can't for the life of me figure it out though. I've messed with autoresizing, but that only seems to work if I do it for each subview, and even though it will scale okay, but because not all the elements are centered they don't end up in the right location in portrait mode.
And as far as for setting the UIViewContentMode, I can get it to work great for individual elements, but not for the view as a whole, and because I'm implementing customized drawing methods, I can't just set it for all the elements individually. Also the who placement issue comes into effect again.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试过调整视图的变换属性?如果你使用CGAffineTransformScale(),你应该得到你想要的效果。
Have you tried adjusting the view's transform property? If you use CGAffineTransformScale(), you should get the effect you want.