How to do it...

  1. If you run the demo app we created in the previous section, you will see that views are not aligned properly, as we didn't add any constraints. For example, check how the label appears when you open the third view controller when you click on the third tab:
  1. As you see, the label is not centered in the iPhone SE simulator.
  1. Using constraints, you can center any view horizontally or/and vertically in its container view. To do this, click on the label that you want to be in the center, press the Ctrl key and drag the label to the super view. A pop-up list of constraints will appear, as follows:
  1. To select multiple constraints ...

Get iOS Programming Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.