Michael Long
1 min readFeb 26, 2019

--

You’re scaling the icons to 9% of the screen width, so 12 of them could run off the screen if the stackview is only constrained to the right edge. Five of them, depending upon screen width, could overlap the “not from earth” label on the left (say, in an iPad split-screen view).

And as I said, with AutoLayout auto-sizing you’re often faced with the fact that you simply can’t abandon an offending constraint that’s impacting the stackview’s subbviews and spacing. Both sides along the stackview’s primary axis need to be pinned.

Changing one of those constraint relations to greater than or less than lets the stackview correctly calculate the intrinsic size of its subviews and as well as the correct spacing, and return that size to the constraints of it’s superview.

If you try it, you’ll see what I mean.

--

--

Michael Long
Michael Long

Written by Michael Long

I write about Apple, Swift, and SwiftUI in particular, and technology in general. I'm also a Lead iOS Engineer at InRhythm, a modern digital consulting firm.

No responses yet