Search code examples
swiftstackview

Set alignment for one member in the stackView


I have a stack view that contains three item, 2 labels (one of them in the left side and another one in the right side), and one view as a separator in the middle. How the configuration of the stackView should look like that the separator has a left alignment. I mean the separator should stay closer to the left item than the right one.

your help will be appreciated.


Solution

  • Give separator a fix width and add another empty UIView() in the stack after separator which will cover the remaining space. This way your right label stay on right and left label with separator aligns left Cheers