Xcode 界面生成器.这些自动调整大小的蒙版设置有何不同? [英] Xcode Interface Builder. How Do These Autosizing Mask Settings Differ?

查看:16
本文介绍了Xcode 界面生成器.这些自动调整大小的蒙版设置有何不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在很习惯在 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
仅使用上锚点自动调整大小 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?

谢谢,
道格

推荐答案

设置1:视图将垂直调整大小,以便保留与父视图顶部的距离和与父视图底部的距离.基本上,视图会随着超级视图而增长和缩小;如果 superview 高 30 像素,这个 view 也会高.

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%,这个 view 也会变高 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 高,subview 是 60px 高,顶部和底部有 20px 的缓冲区.现在让我们将 superview 的大小调整为 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:子视图增长以保留 20 像素的边距,变为 110 像素高.
  • 设置 2:子视图增长 50%(60px -> 90px).上边距仍为 20 像素,但下边距现在为 40 像素.
  • 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 中的行为.如果您有一个主视图/详细视图拆分顶部/底部,并且您希望这两个部分与超级视图按比例增长,则可以使用设置 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 界面生成器.这些自动调整大小的蒙版设置有何不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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