0

I am working on Stackview and adding two labels , I want to adjust position of labels such that the below label should be a bit right side . E.g in UITableViewCell we have one title and second description goes all the way to right along with increasing content in description part.

mainStackView.centerYAnchor.constraint(equalTo: self.view.centerYAnchor),    mainStackView.centerXAnchor.constraint(equalTo: self.view.centerXAnchor)

    ]

    NSLayoutConstraint.activate(mainStackViewConstraints)

    bodyLabel.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 20).isActive = true

Results should looks like this in imageenter image description here

1 Answers1

0

A vertical UIStackView allows Alignment of Fill / Leading / Center / Trailing. The image you've shown does not match any of those.

You could do that with nested stack views... The "second line" would be a horizontal stack view with a "spacer" view to give you the leading space.

However, unless this is just part of a more complex layout, UIStackView is really not the best route.

DonMag
  • 69,424
  • 5
  • 50
  • 86