How do I get a UIStackView to update its layout?
<p>I have a <code>UIStackView</code> with 5 subviews. I want to be able to animate the width of these subviews by updating their <code>intrinsicContentSize</code> or updating their constraints. How can I make the stackView redraw after updating the subview's layout?</p>

<pre><code>        UIView.animateWithDuration(0.3, animations: {
            viewToResize.compressed = true //changes intrinsicContentSize
            viewToResize.invalidateIntrinsicContentSize()
            self.stackView.layoutIfNeeded() //makes no difference
            anotherSubview.hidden = true //adding this makes everything work
})
</code></pre>

<p>I have tried various ways of trying to get the stackView to update, but nothing happens. The only way I can make it work is if I show/hide another subview inside the animation block, then the new layout is animated correctly, but I don't want to do this.</p>

<p>I have seen this question
<a href="https://stackoverflow.com/questions/35365691/animating-uistackview-arrangedsubview-content-size-change">Animating UIStackView arrangedSubview content size change</a>
but the suggested answer does not work (nothing animates).</p>