UITableViewRowAction image for title

changing swipe to delete in UITableViewRowAction to an image button
UITableViewRowAction image for title_第1张图片
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]
    }

你可能感兴趣的:(UITableViewRowAction image for title)