Reputation: 1061
I am trying to change the default button to delete a row in a tableview (when the user swipe left). Changing the height of the default confirmation delete button
At the same time i would like to add a custom image on the left side of the cell when entering the edit mode... [Changing the default icon when entering the edit mode to delete2
I've included in my code the:
func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
return true
}
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
}
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
let delete = UITableViewRowAction(style: .destructive, title: "\u{267A}\n Delete") { (action, indexPath) in
tableView.isEditing = false
print("delete")
// delete item at indexPath
}
return [delete]
}
is it possible to change the heigh of the confirmation delete button and add a custom image for the left icon?
Thanks! :)
Upvotes: 2
Views: 4315
Reputation: 416
You need to set UIImage to backgroundColor of UITableViewRowAction.
let someAction = UITableViewRowAction(style: .Default, title: "") { value in
println("button did tapped!")
}
someAction.backgroundColor = UIColor(patternImage: UIImage(named: "myImage")!)
Upvotes: 0