skip to Main Content

I want my both "bubbles" be aligned to the left.
They are in a stackView with the symbol and the mailLabel.
For some reason shorter text always aligns right.
I tried all distribution settings in the stackView already.

The upper box should be aligned left

Settings stackview

2

Answers


  1. For future reference … when you post a "layout" image, it is very helpful to expand the complete hierarchy, including all of the constraints.

    I’m assuming your horizontal stack view’s Trailing is constrained to the Trailing of the Content View. That tells auto-layout to keep the stack view the *full width of the content view.

    To keep your "bubbles" left-aligned in the Horizontal Stack View, set Distribution: Fill, then constrain its Trailing to be less than or equal to the Content View’s Trailing.

    Assuming you used the "standard" way of setting constraints in IB – where the Content View Trailing is constrained to the Stack View Trailing, it’s "reversed" and should be greater than or equal.

    So, your constraints probably look very close to this:

    enter image description here

    and should be changed to this:

    enter image description here

    Login or Signup to reply.
  2. In code you can always do:

    yourStackView.alignment = .leading
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search