UIView自动化资源 [英] UIView Autoresizing Resources

查看:142
本文介绍了UIView自动化资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直致力于自动化自定义UIView,Apple对此几乎没什么可说的。更重要的是,基于SO反馈,Apple的文档在某些方面实际上是错误的。最后,即使Interface Builder中有六个调整大小的组件,另外六个用于 setAutoresizingMask:,它们似乎根本不相关。例如,在IB中设置宽度弹簧与旋转设备时将 autoresizingMask 设置为 UIViewAutoresizingFlexibleWidth 的效果不同。

I've been working on autoresizing a custom UIView and Apple has very little to say on this. What's more, based on SO feedback, Apple's documentation is actually wrong in some areas. Finally, even though there are six resizing components in Interface Builder and six for setAutoresizingMask: they don't seem to correlate at all. For example, setting the width spring in IB has a different effect from setting the autoresizingMask to UIViewAutoresizingFlexibleWidth when rotating the device.

有没有很好的资源可以了解如何在iPhone上调整大小?

Are there any good resources for learning about how resizing works on the iPhone?

编辑:

我理解Apple使用的基本概念,例如contentMode,我已经阅读了UIView文档。我正在寻找能够更加深入地解释IB设置在程序设计方面可用的内容的方法。

I understand the basic concepts Apple uses such as contentMode, and I've read through the UIView documentation. I'm looking for something that explains a little more deeply what the IB settings do in terms of what's available in the SDK programmatically.

推荐答案

autoresizingMask 设置为 UIViewAutoresizingFlexibleWidth ,相当于设置宽度弹簧加上左右两侧的支柱Interface Builder(struts意味着边缘灵活)。如果要复制仅设置宽度弹簧而不是左右支柱的行为,则必须将 autoresizingMask 设置为 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin

setting the autoresizingMask to UIViewAutoresizingFlexibleWidth, is equivalent to setting the width spring, plus both the left and right struts in Interface Builder (the struts mean that the edge is not flexible). If you wanted to replicate the behavior of only setting the width spring, but not the left and right struts, you would have to set autoresizingMask to UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin

这篇关于UIView自动化资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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