uitableviewcell侧滑删除等

iOS8新增api,重写下2个代理方法

 func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {

        return true

 }

    

func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {

        

        let deleteAction = UITableViewRowAction.init(style: UITableViewRowActionStyle.destructive, title: "删除") { (rowAction, indexPath) in

        }

        

        let editAction = UITableViewRowAction.init(style: UITableViewRowActionStyle.default, title: "编辑") { (rowAction, indexPath) in

        }

        editAction.backgroundColor = UIColor.init(hexString: "d2d2d2")

        

        return [deleteAction,editAction]

  }

原文地址:https://www.cnblogs.com/Leean/p/6836542.html