title: Aligning collection view cells to fit exactly 3 per row
body: <p>I am trying to make a collection view of images, so that there are 3 per row, with no spacing in between.</p>
  
  <p>My collection view data sources are:</p>
  
  <pre><code>func numberOfSections(in collectionView: UICollectionView) -&gt; Int {
      return 1
  }
  
  func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {
      return posts.count
  }
  </code></pre>
  
  <p>and this is how it's set up in my storyboard (imageView width is 125, a third of the 375 screen width):</p>
  
  <p><a href="https://i.stack.imgur.com/4689X.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4689X.png" alt="enter image description here"></a></p>
  
  <p>However when I run the app and add some photos, it looks like this:</p>
  
  <p><a href="https://i.stack.imgur.com/0M1Nt.png" rel="noreferrer"><img src="https://i.stack.imgur.com/0M1Nt.png" alt="enter image description here"></a></p>
  
  <p>How can I fix this so that I see 3 images per row? Thanks for any help!</p>