changing swipe to delete in UITableViewRowAction to an image button
IMG_1912.PNG
You need to set UIImage to backgroundColor of row action, concretely by:
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
let title = " "
let deleteAction = UITableViewRowAction(style: .default, title: title) { (action, indexpath) in
self.contentArray.remove(at: indexPath.row)
tableView.deleteRows(at: [indexPath], with: .automatic)
tableView.reloadData()
}
let image = UIImage(named: "delete_b")
if let im = image {
deleteAction.backgroundColor = UIColor(patternImage: im)
}
return [deleteAction]
}
网友评论