Skip to content

Instantly share code, notes, and snippets.

Created August 3, 2015 10:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/2d404d572b26b321c5fd to your computer and use it in GitHub Desktop.
Save anonymous/2d404d572b26b321c5fd to your computer and use it in GitHub Desktop.
func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [AnyObject]? {
var deleteAction = UITableViewRowAction(style: .Normal, title: " ") { [weak self] action, indexPath -> Void in
self?.deleteItemAtIndexPath(indexPath)
}
let cellBounds = tableView.cellForRowAtIndexPath(indexPath)!.bounds
UIGraphicsBeginImageContextWithOptions(cellBounds.size, true, UIScreen.mainScreen().scale)
var image = UIImage(named: "icon-delete-bin-white")
let yPos = floor((cellBounds.height / 2) - (image!.size.height / 2))
Styling.Color.Red.set()
UIRectFill(cellBounds)
let frame = CGRectMake(20, yPos, floor(image!.size.width), floor(image!.size.height))
image?.drawInRect(frame)
var destImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
deleteAction.backgroundColor = UIColor(patternImage: destImage)
return [deleteAction]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment