Created
November 12, 2015 04:53
-
-
Save soggybag/dedf89498eada5026a50 to your computer and use it in GitHub Desktop.
UITableViewRowAction add custom buttons to a row when swiping
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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