Xcode Interface Builder。这些自动调整遮罩设置有何不同之处? [英] Xcode Interface Builder. How Do These Autosizing Mask Settings Differ?

查看:161
本文介绍了Xcode Interface Builder。这些自动调整遮罩设置有何不同之处?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在非常习惯在IB中使用自动调整面具,但有两种自动调整设置,我不清楚它们是如何区别的:

I am now quite comfortable using autosizing masks in IB but there are two autosizing setting that I am not clear how they are intended to differ:

设置1

使用上下锚点自动调整大小http://dl.dropbox。 com / u / 11270323 / stackoverflow / autosize-mask-0.png

设置2

仅使用uppper锚点进行自动调整http://dl.dropbox.com/u/11270323/stackoverflow/autosize-mask-1。 png

某些背景信息。使用这些设置的UIView子类是子子视图。设置1给了我想要的行为 - 子视图使用其父视图扩展/收缩 - 而设置2以非显而易见的方式略有不同。

Some context. The UIView subclass that uses these settings is a child subview. Setting 1 is giving me the behavior I want - subview expands/contracts with its parent view - while setting 2 is slightly different in a non-obvious way.

什么是这两个设置之间的预期布局差异?

What is the intended layout difference between these two settings?

谢谢,

Doug

Thanks,
Doug

推荐答案

设置1:
视图将垂直调整大小,以便保留超视图顶部的距离和超视图底部的距离。基本上,视图将与superview一起增长和缩小;如果超级视图高出30像素,那么这个视图也会更高。

Setting 1: The view will resize vertically so that both the distance from the top of the superview and the distance from the bottom of the superview are preserved. Basically, the view will grow and shrink in tandem with the superview; if the superview gets taller by 30 pixels, so will this view.

设置2:
视图将垂直调整大小以便保留超视图顶部的距离,并保留视图的比例高度。基本上,视图将与superview按比例增长;如果超级视图高出10%,这个视图也会高出10%。

Setting 2: The view will resize vertically so that the distance from the top of the superview is preserved, and the proportional height of the view is preserved. Basically, the view will grow proportionally with the the superview; if the superview gets taller by 10%, this view will also get taller by 10%.

注意这些在实践中有何不同。假设superview是100px高,子视图是60px高,顶部和底部有20px缓冲区。现在让我们将超级视图的大小调整为150px高。

Note how these differ in practice. Assume the superview is 100px tall, and the subview is 60px tall, with a 20px buffer on the top and bottom. Now let's resize the superview to 150px tall.


  • 设置1 :子视图增长以保持20px的边距,变为110px高。

  • 设置2 :子视图增长50%(60px - > 90px)。上边距仍然是20px,但是下边距现在是40px。

  • Setting 1: The subview grows to preserve the 20px margins, becoming 110px tall.
  • Setting 2: The subview grows by 50% (60px -> 90px). The top margin is still 20px, but the bottom margin is now 40px.

通常,您通常需要设置1中的行为。如果您有一个分割顶部/底部的主/详细视图,并且您希望这两个部分与superview按比例增长,则可以使用设置2。在这种情况下,您可以为两个视图提供灵活的高度,固定顶视图的上边距和底视图的下边距。

In general, you usually want the behavior in Setting 1. You might use Setting 2 if you had a master/detail view split top/bottom, and you wanted both sections to grow proportionally with the superview. In that case, you would give both views flexible height, fixing the top margin of the top view and the bottom margin of the bottom view.

这篇关于Xcode Interface Builder。这些自动调整遮罩设置有何不同之处?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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