如何消除“前导和尾随约束......已经有一个中心约束”警告

Tom*_*scu 3 xcode interface-builder ios autolayout

我正在尝试UIViews在 'or' 附近添加两条 1 像素的线(由 组成)UILabel

一切看起来都很好并且按预期工作,除了我从 Interface Builder 中的第一个图像中收到警告:

当已经存在中心约束时,具有关系“等于”的前导和尾随约束会对文本可以填充的空间造成无益的限制。

我尝试将约束从 = 更改为 >= 或 <=,但没有成功。

知道如何摆脱这个警告吗?谢谢!

Constraints of the first line
Run Code Online (Sandbox Code Playgroud)

Constraints of the label
Run Code Online (Sandbox Code Playgroud)

Constraints of the second line
Run Code Online (Sandbox Code Playgroud)

rob*_*off 5

由于“or”标签上的“Align Center X to: Safe Area”约束而存在警告。要摆脱警告:

  1. 从“or”标签中删除“Align Center X to: Safe Area”约束。
  2. 在左线和右线之间添加“等宽”约束。

通过这两个更改,约束系统仍将被迫将标签居中,但不会有导致警告的 center-x 约束。