ios swift5 tableViewCell 左滑 出现两个点击按钮
·

func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
//创建“解绑”事件按钮
let unbind = UIContextualAction(style: .normal, title: "解绑") {
(action, view, completionHandler) in
//左滑归位
completionHandler(true)
}
unbind.backgroundColor = .lightGray
//创建“授权”事件按钮
let authorize = UIContextualAction(style: .normal, title: "授权") {
(action, view, completionHandler) in
completionHandler(true)
}
authorize.backgroundColor = .gray
//返回所有的事件按钮 数组的第0个元素在最右边
let configuration = UISwipeActionsConfiguration(actions: [authorize, unbind])
return configuration
}
更多推荐



所有评论(0)