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

Macos 我可以使用“自动布局”根据标签大小调整窗口大小吗?,macos,cocoa,autolayout,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 longer label: [an image] [another input]     |
+-------------------------------------------------+
现在我想本地化应用程序。翻译后的标签可能更长,是否可以使用自动布局“推”窗口的宽度

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

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

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

下面是本例中使用的约束: