Reputation: 2262
I am trying to add two 1 pixel lines (made of UIViews
) near the 'or' UILabel
.
Everything looks fine and works as expected, except that I receive the warning from the first image in Interface Builder:
Leading and Trailing constraints with relation "Equal To" can cause unhelpful limitations on the space the text can fill when there is already a center constraint.
I tried changing the constraints from = to >= or <=, but with no success.
Any idea of how to get rid of this warning? Thanks!
Constraints of the first line
Constraints of the label
Constraints of the second line
Upvotes: 3
Views: 935
Reputation: 385600
The warning exists because of the “Align Center X to: Safe Area” constraint on the “or” label. To get rid of the warning:
With these two changes, the constraint system will still be forced to center the label, but it won't have the center-x constraint that is causing the warning.
Upvotes: 5
Reputation: 4333
How about instead of the label, setting an empty UIView between the lines that has the width of the label? Then set the label without left/right constraints centered on the empty view. That way the empty view will adapt to the label without constraining it.
Upvotes: 0