UITableViewRowAction image for t

2017-04-27  本文已影响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]
    }

上一篇下一篇

猜你喜欢

热点阅读