title: Swift - Reduce gap between UICollectionViewCell
body: <p>My <code>UICollectionViewCell</code> doesn't look nice even I implement autolayout and some setting in <code>UICollectionViewCell</code> inspector.</p>
  
  <p>My setting is like this </p>
  
  <p><img src="https://i.stack.imgur.com/Tm0p3.png" alt="enter image description here"></p>
  
  <p>My UICollectionViewCell autolayout</p>
  
  <p><img src="https://i.stack.imgur.com/OzD8u.png" alt="enter image description here"></p>
  
  <p>My ImageView autolayout</p>
  
  <p><img src="https://i.stack.imgur.com/lyLgO.png" alt="enter image description here"></p>
  
  <p>My code</p>
  
  <p>PopularViewController.swift</p>
  
  <pre><code>import UIKit
  import Alamofire
  
  class PopularViewController: UIViewController,UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout {
  
      var users: [JSON] = []
      @IBOutlet var collectionView: UICollectionView!
  
      func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {
          //#warning Incomplete method implementation -- Return the number of items in the section
          return users.count
      }
  
      func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -&gt; UICollectionViewCell {
          let cell = collectionView.dequeueReusableCellWithReuseIdentifier("UserCell", forIndexPath: indexPath) as! PopularCollectionViewCell
  
          cell.user = self.users[indexPath.row]
          return cell
      }
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          Alamofire.request(.GET, "http://128.199.160.213/datetick/users.json").responseJSON { (request, response, json, error) in
  
              if json != nil {
                  var jsonObj = JSON(json!)
                  if let data = jsonObj["users"].arrayValue as [JSON]?{
                      self.users = data
                      self.collectionView.reloadData()
                  }
              }
  
          }
      }
  }
  </code></pre>
  
  <p>PopularCollectionViewCell.swift</p>
  
  <pre><code>class PopularCollectionViewCell: UICollectionViewCell {
  
      @IBOutlet weak var profilePicture:UIImageView!
  
      var user:JSON?{
          didSet{
              self.setupUser()
          }
      }
  
      func setupUser(){
  
          if let urlString = self.user?["profilePhoto"]{
              let url = NSURL(string: urlString.stringValue)
              self.profilePicture.hnk_setImageFromURL(url!)
          }
  
      }
  }
  </code></pre>
  
  <p>My output</p>
  
  <p><img src="https://i.stack.imgur.com/uptJY.jpg" alt="enter image description here"></p>