ga-yo
ga-yo

Reputation: 133

hard to autolayout(stackView in ImageView)

I am making a custom cell using auto layout, but the auto layout is not applied well.

enter image description here

I set auto layout like this Then, in the end, this shape come out. but this shape that The ratio is not right. why it doesn't match..? i set a autolayout on storyboard...

enter image description here

As far as I know, if the image view in the stack view becomes hidden, the unhidden image view is filled in the rest of the stack view space. is it right? if it's right. I make the code

if imageView == nil{

      imageView.isHidden = true }

Upvotes: 0

Views: 88

Answers (1)

DonMag
DonMag

Reputation: 77672

I'm going to guess at some of your constraints...

Here's my example layout:

enter image description here

The "Diamond" image view positions are:

1    3

2    4

Both Vertical stack views (V-Stack-Left and V-Stack-Right) have the same settings:

enter image description here


If we set Alignment: Center for the Horizontal stack view (H-Stack):

enter image description here

Setting diamond4.isHidden = true gives this result:

enter image description here


If we set Alignment: Top for the Horizontal stack view (H-Stack):

enter image description here

Setting diamond4.isHidden = true gives this result:

enter image description here

Upvotes: 1

Related Questions