美文网首页
UITableViewRowAction image for t

UITableViewRowAction image for t

作者: 倾世圣伊 | 来源:发表于2017-04-27 16:59 被阅读0次
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]
    }

相关文章

网友评论

      本文标题:UITableViewRowAction image for t

      本文链接:https://www.haomeiwen.com/subject/fhknzttx.html