title: Keep UITableViewCell in front of other cells
body: <p>I am trying to keep the lower cells in front of the cells above them. I have a subview in a cell that would ideally go behind the cell below. I am having trouble finding where to put the code to do this. I think I am supposed to use this snippet of code:</p>
  
  <pre><code>for i in 0 ..&lt; arrayWarningTitles.count{
          let cell = tableView.cellForRowAtIndexPath(NSIndexPath(forRow: i, inSection: 0))
          self.tableView.bringSubviewToFront(cell!)
  }
  </code></pre>
  
  <p>but I am not sure where, as I have tried a few different places and none have worked (willDeselectRowAtIndexPath and didSelectRowAtIndexPath), and I would also like it on the initial load up as well. Any suggestions would be greatly appreciated!</p>
  
  <p><strong>UPDATE (Added Table View Code)</strong>:</p>
  
  <p>Here is the bulk of my Table View code, if it helps anyone, I have removed the above snippet as it is not working.</p>
  
  <pre><code> override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
      selection = indexPath.row
      tableView.beginUpdates()
      tableView.endUpdates()
      //  self.tableView
  }
  
  override func tableView(tableView: UITableView, willDeselectRowAtIndexPath indexPath: NSIndexPath) -&gt; NSIndexPath? {
      tableView.beginUpdates()
      tableView.endUpdates()
  
  
      return indexPath;
  }
  
  override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell{
      let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath)
      cell.selectionStyle = UITableViewCellSelectionStyle.None
      cell.backgroundColor = UIColor.clearColor()
      // Configure the cell...
  
      let warningTitle = self.view.viewWithTag(1) as? UILabel
      let expirationTime = self.view.viewWithTag(2) as? UILabel
      let textView = self.view.viewWithTag(5) as? UITextView
      let grayBackground = self.view.viewWithTag(6)
      let redBackground = self.view.viewWithTag(7)
  
      warningTitle?.text = arrayWarningTitles[indexPath.row]
  
      redBackground!.layer.masksToBounds = true;
      redBackground!.layer.cornerRadius  = 20;
      grayBackground!.layer.masksToBounds = true;
      grayBackground!.layer.cornerRadius  = 20;
  
      redBackground?.clipsToBounds = false;
      cell.clipsToBounds = false;
      cell.contentView.clipsToBounds = false;
      cell.contentView.superview?.clipsToBounds = false;
      self.tableView.bringSubviewToFront(cell)
      return cell
  }
  
  override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -&gt; CGFloat
  {
  
  
      if (indexPath.row == selection) { //change 0 to whatever cell index you want taller
          return UIScreen.mainScreen().bounds.height - 140 - 64;
      }
      return 58;//Choose your custom row height
  }
  </code></pre>