Skip to content

Instantly share code, notes, and snippets.

@soggybag
Created November 12, 2015 04:53
Show Gist options
  • Save soggybag/dedf89498eada5026a50 to your computer and use it in GitHub Desktop.
Save soggybag/dedf89498eada5026a50 to your computer and use it in GitHub Desktop.
UITableViewRowAction add custom buttons to a row when swiping
func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? {
let complete = UITableViewRowAction(style: .Normal, title: "Complete") { (action: UITableViewRowAction, indexPath: NSIndexPath) -> Void in
self.completeRowAtIndexPath(indexPath)
}
complete.backgroundColor = UIColor.greenColor()
let delete = UITableViewRowAction(style: .Destructive, title: "Delete") { (action: UITableViewRowAction, indexPath: NSIndexPath) -> Void in
self.deleteRowAtIndexPath(indexPath)
}
delete.backgroundColor = UIColor.redColor()
return [complete, delete]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment