Is there a way to keep subviews of a UIStackView participating in autolayout when they're hidden?

It is by design that hidden arranged subviews are not only hidden but no longer contribute to the layout either. It's a major feature that cannot be achieved easily with auto layout.

If you want to prevent this, then you can wrap your view within another view. Instead of hiding the direct subview of the UIStackView (the wrapper view in the new setup), hide the inner view (the same way as in the old setup except it is now nested). As the direct subview is visible, UIStackView won't reclaim the space. But the user can't see any content as the view content is hidden.


Instead of hiding the subview, you can just turn its alpha to 0. This way the subview won't be visible but it will participate in the layout.