sesc360
sesc360

Reputation: 3255

Stackview with right aligned label needs padding

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

Upvotes: 3

Views: 2521

Answers (1)

Michael Long
Michael Long

Reputation: 1092

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.

Upvotes: 2

Related Questions