Hug subviews in SwiftUI : <p>Dave Abrahams explained some of the mechanics of SwiftUI layouts in his WWDC19 talk about Custom Views, but he left out some bits and I have trouble getting my views properly sized. </p>

<p><strong>Is there a way for a View to tell its container that it is not making any space demands, but it will use all the space it is given? Another way to say it is that the container should hug its subviews.</strong></p>

<p>Concrete example, I want something like c:</p>

<p><a href="https://i.stack.imgur.com/nuA4r.png" rel="noreferrer"><img src="https://i.stack.imgur.com/nuA4r.png" alt="Some Texts inside a VStack"></a></p>

<p>If you have some <code>Text</code>s inside a <code>VStack</code> like in a), the <code>VStack</code> will adopt it's width to the widest subview.</p>

<p>If you add a <code>Rectangle</code> though as in b), it will expand as much as it can, until the <code>VStack</code> fills <em>its</em> container.</p>

<p>This indicates that <code>Text</code>s and <code>Rectangle</code>s are in different categories when it comes to layout, <code>Text</code> has a fixed size and a <code>Rectangle</code> is greedy. <strong>But how can I communicate this to my container if I'm making my own <code>View</code>?</strong></p>

<p>The result I actually want to achieve is c). VStack should ignore Rectangle (or my custom view) when it determines its size, and then once it has done that, <em>then</em> it should tell Rectangle, or my custom view, how much space it can have.</p>

<p>Given that SwiftUI seems to layout bottom-up, maybe this is impossible, but it seems that there should be <code>some</code> way to achieve this.</p>
