Search code examples
iosswiftuitableviewtableviewuitableviewrowaction

iOS: Trash Can Delete Button for UITableViewCell in Swift


Is there a way to add this icon to a UITableViewRowAction when a UITableView's UITableViewCell is swiped right, without setting the patternImage of the UITableViewRowAction's background?

i.e. add access this icon:

,

into the following code:

func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {

    let delete = UITableViewRowAction(style: .destructive, title: "", handler: {})

}

Solution

  • This is not currently possible, but will be possible in iOS 11. Here is a tutorial for implementing these custom actions:

    https://developerslogblog.wordpress.com/2017/06/28/ios-11-swipe-leftright-in-uitableviewcell/