3

I created the following layout:

enter image description here

The label on the right side, is included in a stackview, but is "clinging" to the right side of the screen when launching the app. I want to achieve some spacing, but don't know how to achieve it.

The expected output would look like this: enter image description here

sesc360
  • 3,155
  • 10
  • 44
  • 86

1 Answers1

2

When isLayoutMarginsRelativeArrangement property is true, the stack view will layout its arranged views relative to its layout margins. So here,

stackView.layoutMargins = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 20)
stackView.isLayoutMarginsRelativeArrangement = true

The above will add 20 pixels width of padding to the right edge of the stackview. This can also be done via the storyboard.

Michael Long
  • 1,046
  • 8
  • 15