ios – ImageView inside horizontal StackView is just not respecting constraint top


I’ve a horizontal UIStackView: on the left there is a UIImageView and on the best labels and buttons.

I hardcoded the imageview to be 60×60 (with constraints). Nonetheless, as a result of the best aspect wants a bit extra vertical house, the overall top of the stack turns into 84. Wanting to maintain the picture centered vertically, I set the imageview’s centerY to equal its superview (the stack). In Interface Builder every little thing appears to be like because it ought to.

After I run the app nonetheless, the imageview resizes itself to 60×84, utterly disregarding the peak constraint (and even the 1:1 facet ratio constraint). I regarded on the Debug View Hierarchy and I can see the constraints there, however they’re greyed out.

I attempted .aspectFit and even manually including the peak constraint at runtime however nothing modifications. Be aware: aspectFit facilities the picture and reveals it as 60×60, however its body continues to be 60×84

Any ideas?

Leave a Reply

Your email address will not be published.