Adding Constraints
By adding constraints, you allow the compiler to automatically calculate the position of your controls. When you first add constraints, the drawn line of the constraint may be orange, or it may be blue. It’s important to know that when the line is orange, it means that you have not given Xcode enough information to calculate the constraint fully, and therefore it cannot properly position your item. It is not until your constraints turn blue that you can be sure that they are going to work.
To add a simple constraint to your button, Control+drag the button to the left and let go (in the whitespace area). A dialog appears, allowing you to choose a constraint. Choose Center Vertically in Container. You should now have an orange ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access