左侧是布局的正常状态。右边是布局的展开状态。
我的问题是我无法弄清楚如何使粉红色框居于其单元格的中心,并且随着布局向任何方向的增长,绿线连接在粉红色框之间。仅具有这两个视图的AutoSizing.xib可以在这里找到:https ://dl.dropboxusercontent.com/u/6979623/AutoSizing.xib
有两种方法可以使粉红色框居中于超级视图的四个象限内:
You can add four invisible views that even split up the four quadrants of this main view (using constraints to pin them to their respective corners and another set of constraints to make them equal widths and heights). If I were going to represent that in VFL (just because it's a concise way of representing all of those constraints), it might be something like:
H:|[quadrant1][quadrant2(==quadrant1)]|
H:|[quadrant3(==quadrant1)][quadrant4(==quadrant1)]|
V:|[quadrant1][quadrant3(==quadrant1)]|
V:|[quadrant2(==quadrant1)][quadrant4(==quadrant1)]|
You can then center the pink views in the center of each of those four quadrant views.
You can add center constraints that employ multipliers to offset these pink squares within their shared superview. Interface Builder has only recently gotten multiplier support and it's not super solid, in my opinion, so when I want to use multipliers, I often fall back to adding those programmatically.
正确放置粉红色框后,它们之间的绿线分别是固定的水平/垂直线的前/后或前/后的间距。将其与固定的宽度和中心对齐方式结合起来即可完成。底线,请注意上面讨论的粉红色框的放置,然后创建绿线变得非常容易。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句