title: UITableViewCell color doesen't remain the same after i set it in his class
body: <p>In my <code>UITableViewCell</code> class, i have a function who configures the cellViewColor. I have an array of objects and based on some fields i determinate if the cellView should be gray, red or turquoise. When the table view reuses the cell, it changes the colors in random ways. </p>
  
  <pre><code>class WidgetCell: UICollectionViewCell {
  @IBOutlet weak var cellView: UIView!
  @IBOutlet weak var mainValue: UILabel!
  @IBOutlet weak var placeDetails: UILabel!
  @IBOutlet weak var place: UILabel!
  @IBOutlet weak var image: UIImageView!
  
  
  func configureCell(entity: EntityModel) {
      self.mainValue.text = entity.monitor?.value
      self.placeDetails.text = entity.name
      self.place.text = entity.name
      self.cellView.applyGradient(withColours: setDeviceStateColor(deviceState: helper(entity: entity) ))
  }
  
  private func setDeviceStateColor(deviceState: DeviceState) -&gt; [UIColor] {
      switch deviceState {
      case .alert:
          return [UIColor.red, UIColor.red]
      case .on:
          return [Colors.lightTurcoazLIH, Colors.mediumTurcoazLIH]
      case .off:
          return [UIColor.lightGray,UIColor.darkGray]
      }
  }
  
  
  extension UICollectionViewCell {
  func helper(entity: EntityModel) -&gt; DeviceState {
      let state = entity.monitor?.state ?? false
      let alert = entity.monitor?.alert ?? false
      if state &amp;&amp; alert {
          return .alert
      } else if state &amp;&amp; alert == false {
          return .on
      } else {
          return .off
      }
  }
  </code></pre>
  
  <p>Is something related to the deque of the cells.</p>
  
  <pre><code>func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell {
      let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! WidgetCell
      cell.configureCell(entity: favoriteDevices[indexPath.row])
  
      return cell
  }
  </code></pre>
  
  <p>I hope it's all clear and my explanations are making sense. </p>
  
  <p>Also, here it is the applyGradient(withColors:) </p>
  
  <pre><code>func applyGradient(withColours colours: [UIColor]) {
      let gradient: CAGradientLayer = CAGradientLayer()
      gradient.frame = self.bounds
      gradient.cornerRadius = 3
      gradient.colors = colours.map { $0.cgColor }
      gradient.startPoint = CGPoint.init(x: 0.0, y: 0.0)
      gradient.endPoint = CGPoint.init(x: 0.0, y: 1.0)
      self.layer.insertSublayer(gradient, at: 0)
  }
  </code></pre>