Search code examples
iosswiftuistackview

StackView with Labels on the ends


Is it possible to have a stack view with two labels in it, but instead of being trailing or leading aligned, the labels are aligned to the edges? Thanks.

Stack View


Solution

  • Most straightforward way...

    Give your stack view these properties:

    enter image description here

    Constrain the stack view Top/Leading/Trailing and desired Height constraints.

    Give the Left Label desired Width and Height constraints.

    Constrain Right Label equal Width and Height to Left Label.

    Looks like this:

    enter image description here