如何利用X code汽车布局有一个观点调整大小 [英] How to have a view resize using Xcode's auto layout

查看:148
本文介绍了如何利用X code汽车布局有一个观点调整大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的一个项目,我有几个NSPopUpButtons第一次X code'S自动排版功能。
现在我想实现是有连续2 popUpButtons连同它们的标签,当窗口大小我想这两个popUpButtons来,同时保持彼此之间的水平间距调整它们的宽度。

I am using Xcode's auto layout feature for the first time in a project where I have several NSPopUpButtons. Now what I want to achieve is to have two popUpButtons in a row together with their labels and when the window is resized I want both popUpButtons to adjust their width while keeping the horizontal spacing between each other.

不过不管我怎么申请我只是不明白的popUpButtons与窗口中更改它们的大小的限制。他们总是会打破他们的水平间距限制,只是增加/减少间距的标签。我希望它变得更清楚一点我从这张截图完成的:

However no matter how I apply the constraints I just don't get the popUpButtons to change their size with the window. They will always break their horizontal spacing constraints and just increase/decrease the spacing to the labels. I hope it gets a bit clearer what I have done from this screenshot:

我已经设置了标签和popUpButtons之间的间距为固定值与1000的优先级和所设定的宽度约束FO的popUpButtons到大于或等于初始大小

I have set the spacings between the labels and the popUpButtons to fixed values with 1000 priority and have set the width constraints fo the popUpButtons to be greater or equal to the initial size.

必须如何设置我的约束,有popUpButtons调整?

How must I set my constraints to have the popUpButtons resize?

推荐答案

在写这个问题,我意识到了什么诀窍是:

While writing this question I realized what the trick is:

在NSPopUpButton的尺寸检查我不得不降低内容拥抱优先

In the size inspector of the NSPopUpButton I had to reduce the Content Hugging Priority.

显然,这控制的观点如何紧密地想'拥抱'的内容。因此,当拥抱优先级高于优先级调整大小视图不会想增加它的大小更高,因为这将意味着有它的界限和它的内容之间更多的空白空间。

Obviously this controls how closely the view wants to 'hug' its content. So when the hugging priority is higher than the resize priority the view will not want to increase its size because that would mean to have more empty space between its bounds and its content.

然后在我的特殊情况,我也都销到NSPopUpButtons具有相同的宽度就万事大吉了。同时保持间距不变的popUpButtons将完全调整

Then in my special case, I could also pin both NSPopUpButtons to have the same width and voilà: the popUpButtons will perfectly resize while keeping the spacing constant.

这篇关于如何利用X code汽车布局有一个观点调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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