【问题标题】:AutoLayout how to auto expand labelAutoLayout如何自动展开标签 【发布时间】:2017-02-04 17:46:44 【问题描述】: 使标签自动扩展其宽度以更改文本长度以及将相邻标签推到一边的正确约束是什么? 【问题讨论】: Using Auto Layout, how do I make two labels on the same "line" be dynamic in their widths (adjusting with how wide each one needs to be)?的可能重复 标签: ios autolayout 【解决方案1】: 如果您不指定标签的宽度,这应该可以工作。它将根据内容设置大小。给Label3 和Label4 约束以垂直放置它们。给 Label4 一个尾随约束到 superview。给 Label3 一个尾随约束到 Label4 前导。 【讨论】: 感谢您的回答,我意识到,由于我在 UIScrollView 中使用视图,如果没有设置所有约束,它会变得非常混乱