title: Dynamic Width Cell in UICollectionView
body: <p><a href="https://i.stack.imgur.com/eEsrg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eEsrg.png" alt="enter image description here"></a></p>
  
  <p>I try to implement labels with <code>UICollectionView</code>. But I have to set the widths with dynamic labels length. I try to remove gaps in picture. I share some code. I use Nibs.</p>
  
  <p>Thanks in advance.</p>
  
  <pre><code>layoutFCV.estimatedItemSize = UICollectionViewFlowLayout.automaticSize
  let filterCV = UICollectionView(frame: self.view.bounds, collectionViewLayout: layoutFCV)
  </code></pre>
  
  <p>--</p>
  
  <pre><code>func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -&gt; CGSize {       
      if collectionView == filterCollectionView {
          let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "FilterSelectionCollectionViewCell", for: indexPath) as! FilterSelectionCollectionViewCell
          return CGSize(width: cell.title.frame.width , height: self.filterCollectionView.frame.height)
      }  else {
          return CGSize(width: 10, height: 10)
      }
  }
  </code></pre>