Skip to content

Instantly share code, notes, and snippets.

@theHellyar
Created November 5, 2014 21:26
Show Gist options
  • Save theHellyar/e611051901ed9ce44a5d to your computer and use it in GitHub Desktop.
Save theHellyar/e611051901ed9ce44a5d to your computer and use it in GitHub Desktop.
editActionsForRowAtIndexPath with optional image as background
func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [AnyObject]? {
var deleteAction:UITableViewRowAction = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: "Delete", handler: { (tvra:UITableViewRowAction!, indexPath:NSIndexPath!) -> Void in
self.baseArray[indexPath.section].removeAtIndex(indexPath.row)
tableView.reloadData()
})
//Change background color
deleteAction.backgroundColor = UIColor(red: 203/255, green: 76/255, blue: 76/255, alpha: 1)
//Optional use image as background, remove 'title' text in declaration / Not ideal implimentation
//deleteAction.backgroundColor = UIColor(patternImage: UIImage(named:"sample")!)
return [deleteAction]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment