Created
November 5, 2014 21:26
-
-
Save theHellyar/e611051901ed9ce44a5d to your computer and use it in GitHub Desktop.
editActionsForRowAtIndexPath with optional image as background
This file contains 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) -> [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