Skip to content

Instantly share code, notes, and snippets.

@jimbrayrcp
Created May 6, 2020 16:19
Show Gist options
  • Select an option

  • Save jimbrayrcp/d9876a68360202a382e7a6c2e5dd3265 to your computer and use it in GitHub Desktop.

Select an option

Save jimbrayrcp/d9876a68360202a382e7a6c2e5dd3265 to your computer and use it in GitHub Desktop.
Swift 5: iOS: 13.1 - tableView Swipe Left Delete Action (or any function you want to add) Uses system images
override func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
let deleteAction = UIContextualAction(style: .normal, title: "Delete", handler: { (ac:UIContextualAction, view:UIView, success:(Bool) -> Void) in
// *** add the object you want to delete here ***
// object.delete
success(true)
})
deleteAction.backgroundColor = .red
deleteAction.image = UIImage(systemName: "trash.fill")
deleteAction.backgroundColor = .green
return UISwipeActionsConfiguration(actions: [deleteAction])
}
@jimbrayrcp

Copy link
Copy Markdown
Author

For swipe Right with Images:
Go To Swipe Right with Images:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment