title: How to change the color of a UIButton in a Table View Cell in Swift?
body: <p>I have a custom TableViewCell that has a product name, product image, and button. In the same TableViewController there is a search bar that will pull up the specific products based on the name. When I search I can click on the button for the product and I would like for it to change color, from green to red and the text to change from "original color" to "changed color". This works until I cancel the search, then the button reverts back to its original form. This is the function, if you need to know anything else let me know. Thanks in advance.</p>
  
  <pre><code>  @IBAction func changeColorAction(sender: UIButton)
  {
  
      sender.backgroundColor = UIColor.redColor()
      sender.setTitle("changed Color", forState: UIControlState.Normal)
  
  }
  </code></pre>
  
  <p>This is where I call the function:</p>
  
  <pre><code>   override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
  
      let cell = self.tableView.dequeueReusableCellWithIdentifier("cell") as! CustomSearchCell
  
      var user : UserItem
  
      if(tableView == self.searchDisplayController?.searchResultsTableView)
      {
          user = self.filteredProducts[indexPath.row]
      }
      else
      {
          user = self.productsArray[indexPath.row]
      }
  
      cell.followButton.addTarget(self, action: "changeColorAction:", forControlEvents: .TouchUpInside)
  
      cell.configureCellWith(user)
  
      return cell
  }
  </code></pre>