title: Swift: gradient on a cell of a tableview
body: <p>On tableView's cells, I'm trying to define a gradient with the following Swift code:</p>
  
  <pre><code>func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -&gt; UITableViewCell! {
  
      var cell:UITableViewCell = self.tableView?.dequeueReusableCellWithIdentifier("cell") as UITableViewCell
      cell.backgroundColor=UIColor.clearColor()
      let gradient : CAGradientLayer = CAGradientLayer()
      var arrayColors:Array&lt;AnyObject&gt; = [UIColor.blackColor().CGColor, UIColor.whiteColor().CGColor]
      gradient.colors=arrayColors
      gradient.frame = cell.bounds
      cell.layer.insertSublayer(gradient, atIndex: UInt32(indexPath.row))
  
      return cell
   }
  </code></pre>
  
  <p>The behavior is very chaotic: when the view is first loaded, all cells have a white background. And if I scroll up and down, some content's cells disappear (title and subtitle) and the gradient finally appears in these cells (randomly, some other cells stay with a white background).
  Is it related to this cast -> UInt32(indexPath.row) ?</p>