UIView 自动调整资源 [英] UIView Autoresizing Resources

查看:24
本文介绍了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 设置在 SDK 中以编程方式提供的内容的作用的内容.

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,相当于设置了spring的宽度,加上左右两边Interface Builder 中的右支柱(支柱意味着边缘灵活).如果您想复制仅设置宽度弹簧而不是左右支柱的行为,则必须将 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天全站免登陆