iOS/Swift: Dynamically size UIStackView when one of its items gets larger

Make sure you don't have a bottom constraint of a height constraint on the stackview. You should only need left, right and top constraint.


I had this on iOS 12, while it was working fine on iOS 13. Just set:

stackView.distribution = .fillProportionally

Fixed it :)


You should call sizeToFit() and layoutIfNeeded() on the subviews of the stackView. Constrain the UIStackView as you normally would, and constrain the subviews as you normally would.

Also, you need to have it set to Fill Proportionally and it will resize to fit the new content.