Created
August 3, 2015 10:59
-
-
Save anonymous/2d404d572b26b321c5fd to your computer and use it in GitHub Desktop.
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) -> [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