title: Change cell border color in UICollectionView?
body: <p>I would like to change the border color when a user touches the cell. I have the following code in my UICollectionView but it's not working:</p>
  
  <pre><code>override func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
  
          self.user["avatar"] = self.avatars[indexPath.row]
  
          do {
             try self.user.save()
          } catch {
              print(error)
          }
  
          //self.performSegueWithIdentifier("returnToProfile", sender: user)
          let cell = collectionView.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: indexPath) as! AvatarViewCell
          cell.layer.borderWidth = 5.0
          cell.layer.borderColor = UIColor.yellowColor().CGColor
  
      }
  </code></pre>
  
  <p>Thanks!</p>
  
  <p>EDIT: I tried the top-voted answer in the question that was flagged as a duplicate but it still doesn't work. <code>cell.layer.borderColor = UIColor.yellowColor().CGColor</code> doesn't change the color. </p>
  
  <p>Maybe it's an issue with how I'm defining cell?</p>