title: How to make dynamic height for UICollectionViewCell with dynamic type and fixed width?
body: <p>I am working on a project where we use a <strong>UICollectionView</strong> with a <strong>custom</strong> cell. The cell looks like <a href="https://i.stack.imgur.com/eLzCX.png" rel="nofollow noreferrer">this</a>. All of my elements are contained in a UIView.
  Of course, the text is much shorter.
  Anyway, I decide the width of the CollectionView in the <em><strong>sizeForItemAt</strong></em> function:</p>
  <pre><code>func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -&gt; CGSize {
      return CGSize(width: collectionView.frame.width - 50, height: (collectionView.frame.width * 0.7))
  }
  </code></pre>
  <p>I need to find a way to keep this fixed width but to make the height of the cell resizable when dynamic type is enabled. The labels at the bottom of the cell must be able to grow in size and therefore resize the cell at the bottom as much as they need without affecting the ImageView's size at the top. However, this seems harder than it looks since my ImageView has a size of 0.7 * the width of my CollectionView (so it has a proper height in any screen).</p>
  <p>My labels are contained in a VerticalStackView and my VerticalStackView and the &quot;1&quot; label are contained in a HorizontalStackView.
  I have tried to use dynamic type on this kind of view hierarchy in a sample project and the view grows in height without affecting the ImageView but I cannot seem to do the same in a CollectionViewCell.</p>
  <p>I tried using auto-layout with Automatic Size enabled for my CollectionViewCell but that just ruins both my width and height and also clips the labels that I cannot see them anymore.</p>
  <p>I hope you can help me!</p>
  <p>Thank you so much.</p>