Reputation: 971
I would like to get my StackView centered on the screen and also add a padding on each sides (left & right) of 20 to get margin with the screen:
but the left margin is not taken into account:
result is the following:
how can I handle the right margin ? I also had the same problem for other type of objects (not a StackView).
Upvotes: 1
Views: 234
Reputation: 181
make sure you are only using the minimum number of constraints needed to establish the frame for your view. For example:
Incorrect examples would be:
The other thing I'm seeing is that you don't have any constraints for top / bottom / height (the vertical axis) so Interface Builder is warning you that you don't have enough constraints to correctly position the view. Make sure that you don't have any red errors or red constraints in Interface Builder, otherwise the layout is undefined or ambiguous.
Upvotes: 1