我可以根据标签尺寸使用自动布局调整窗口大小吗?

时间:2015-08-18 08:35:23

标签: macos cocoa autolayout

我有一个窗口,其形式如下:

+-------------------------------------------------+
|       Label one: [an image] [some other input]  |
|  A longer label: [an image] [another input]     |
+-------------------------------------------------+

现在我想本地化应用程序。翻译的标签可能会更长,是否可以使用自动布局“推”窗口的宽度?

+------------------------------------------------------+
|            Label one: [an image] [some other input]  |
|  A much longer label: [an image] [another input]     |
+------------------------------------------------------+

1 个答案:

答案 0 :(得分:1)

当然!如果标签没有固定的宽度,它们会自动增长。只需设置前导和尾随约束,他们就会尝试获得所需的空间。

您也可以使用预览功能在Xcode中测试:

English Some other language

以下是此示例中使用的约束:

Constraints

相关问题