How to do it

  1. As usual, let's create a new Xcode project with Single View template and name it StackViews.
  2. Open the storyboard file and select the view controller and change its size to iPhone 4-inch.
  3. From Object Library, drag a Vertical stack view and add it as a subview.
  4. Change its frame to (X = 20, Y = 20, Width = 280).
  1. We need to add constraints to make the stack view's left, right, and top margins to be equal to 20 and to make its height = 75% of the device screen. To do so, first select the stack view, and click on the Pin button and set the top, left, and right constraint values to 20:
  1. For the height constraint, drag the stack view ...

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.