oky_sabeni
oky_sabeni

Reputation: 7822

How do I set a top layout constraint for a stack view that is embedded in another stack view?

Image

I want to set a vertical gap of 5px between the give label and the top of the GiveLabelStack view. When I set it using layout constraints, I get an error; see below. Stack view automatically adds a constraint of give.top = GiveLabelStack.top. In addition, I can't select to delete and remove the constraint.

Can't delete the constraint

On this image, I can't select the give.top = GiveLabelStack.top to remove.

Does anyone how I can achieve this?

Thanks

Upvotes: 1

Views: 440

Answers (1)

rob mayoff
rob mayoff

Reputation: 386008

Put the label inside its own vertical stack view (which is inside the horizontal GiveLabelStack). Set the vertical stack view's top layout margin to 5.

Before:

before extra stack

After:

after extra stack

Here's where you set the stack view's layout margins:

setting the layout margins

Upvotes: 1

Related Questions