3
votes

I'm trying to center a view inside a UIScrollView using the interface builder only. With labels seems to be working well.

enter image description here enter image description here

But when I try to do the same with a UIView, I'm having constraints conflicts.

enter image description here enter image description here enter image description here

The conflicts make sense, but if I delete the width/height constraints the UIView extends to the entire SuperView, and if I delete the top/lead/trail/bottom constraints, the UIView correctly centers itself, but I get an ambiguous width/height warning.

enter image description here

My question would be, How can I get the UIView centered the same as the UILabel?.

1

1 Answers

2
votes

For future reference:

enter image description here enter image description here

But the key thing was to set a different ContentHugging priority, to help AutoLayout work out conflicts:

enter image description here