Created
May 6, 2020 16:19
-
-
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
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
| 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]) | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For swipe Right with Images:
Go To Swipe Right with Images: