functableView(_tableView:UITableView, editActionsForRowAt indexPath:IndexPath) -> [UITableViewRowAction]? {
letdeleteAction =UITableViewRowAction.init(style: .normal, title:nil) { (action, indexPath)in
tableView.setEditing(false, animated:true)
}
letdisLoveAction =UITableViewRowAction.init(style: .normal, title:nil) { (action, indexPath)in
tableView.setEditing(false, animated:true)
}
return[deleteAction,disLoveAction]
}
functableView(_tableView:UITableView, willBeginEditingRowAt indexPath:IndexPath) {
self.editingIndexPath= indexPath
self.viewDidLayoutSubviews()
}
functableView(_tableView:UITableView, didEndEditingRowAt indexPath:IndexPath?) {
self.editingIndexPath =IndexPath.init()
}
overridefuncviewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
if#available(iOS11.0, *) {
forsubviewinself.table.subviewswheresubview.isKind(of:NSClassFromString("UISwipeActionPullView")!) {
ifsubview.subviews.count>=2{
// subview.backgroundColor = ColorTheme
self.configDeleteButton(button: subview.subviews[1]as!UIButton)
self.configDisLoveButton(button: subview.subviews[0]as!UIButton)
}
}
}else{ // IOS 10以及以下
forsubviewinself.table.subviewswheresubview.isKind(of:NSClassFromString("UITableViewCellDeleteConfirmationView")!) {
ifsubview.subviews.count>=2{
self.configDeleteButton(button: subview.subviews[0]as!UIButton)
self.configDisLoveButton(button: subview.subviews[1]as!UIButton)
}
}
}
}
funcconfigDeleteButton(button :UIButton){
button.backgroundColor = ColorLine
button.setImage(UIImage.init(named:"tableDelete"), for: .normal)
button.addTarget(self, action:#selector(self.Delete), for: .touchUpInside)
}
funcconfigDisLoveButton(button :UIButton){
button.backgroundColor = ColorLine
button.setImage(UIImage.init(named:"tableDisLove"), for: .normal)
button.addTarget(self, action:#selector(self.DisLove), for: .touchUpInside)
}
@objcprivatefuncDelete(){
}
@objcprivatefuncDisLove(){
}