问题描述
我有一个大约有50个UIButton的UIView。所有按钮位置都以像素为单位,相对于我的主UIView的左上角。
I have an UIView with around 50 UIButtons. All button positions were given in pixels, relative to the left upper corner of my main UIView.
视图中使用的所有(背景)图像都有更高的分辨率。当我将我的应用程序从iPhone移植到iPad时,我想增加UIView的有效像素大小。
All (background) images used in the view are available in higher resolution. As I am porting my app from iPhone to iPad, I would like to increase the effective pixel size of the UIView.
现在我正在寻找一种升级整体的方法UIView系数为2 *。这是否可能不破坏内部元素的位置?
Now I'm searching a way to upscale the whole UIView by a factor of 2*. Is that possible without destroying the position of the inner elements?
仅供参考,UIView是在XCode的NIB文件中设计的。但是我不介意它是否可以通过编程方式完成。
FYI, the UIView is designed in a NIB-file in XCode. But I don't mind if it can be done programmatically.
推荐答案
我最终使用了
self.view.transform = CGAffineTransformScale(CGAffineTransformIdentity, 2, 2);
它允许我保留在Interface Builder中创建的设计。
It allowed me to keep the design created in the Interface Builder.
不幸的是,在这种情况下图像的清晰度会受到影响,但与以编程方式编写整个设计脚本相比,这是一个很小的代价。
Unfortunately the sharpness of the image suffers in that case, but this is a small price to pay compared to scripting the whole design programmatically.
这篇关于缩放UIView及其所有子项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!