“Fixed leading and trailing constraints may cause clipping” bug?

柔情痞子 提交于 2019-12-04 04:23:17
Pranay

If you're still looking for an answer, in your particular case, try setting a proportional width on your label and center horizontally in the view controller's view.

Clear all your constraints on the label, right-click drag from the label to the Background View and select Equal Widths, Center Horizontally in Container, and Center Vertically in Container from the popup menu.

Now since you said you wanted 20px margin both to the left and right of your label, edit the Multiplier on the equal width constraint and set it to widthOfBackgroundView - 40)/widthOfBackgroundView.

So let's say the width of your background view is 414, the multiplier is supposed to be 374/414.

The reason for the width minus 40 multiplier is it covers 20px on either sides of the label. This should make your warning go away and layout the label the way you're expecting it to be.

I had the same issue and was able to fix the warnings this way. Hope this helps!

valvoline

Some problem here, introduced with the final version of Xcode 9. Seems that the bug is related to the language direction: for some reason Interface Builder doesn't understand quite well the autolayout for the default language direction conditions.

As suggested by Repose on this thread you should try to invalidate the use of language direction for at least one of the failing constraints (ie. trailing). This approach solved my warnings.

OMGHaveFun

Checked in Xcode 9GM (Version 9.0 (9A235)), it works correctly

Remove the constraints and add them manually.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!