首页 > 解决方案 > Swift 自定义 TableView 尾随动作视图

问题描述

我有TableView一个trailingSwipeAction

这是我的代码:

func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {

    let deleteAction = UIContextualAction(style: .destructive, title: "Delete".localized()) {[unowned self] _, _, completionHandler in
            let selectedUser = self.friendsDataSourceArray[indexPath.section]
            self.friendsDataSourceArray.remove(at: indexPath.section)
            let indexSet = IndexSet(arrayLiteral: indexPath.section)
            self.theTableView.deleteSections(indexSet, with: .fade)
            self.theTableView.reloadData()
            DataHandler.removeFriend(friendId: selectedUser.uid)
            completionHandler(true)
        }
        deleteAction.backgroundColor = .redCustom
        deleteAction.image = UIImage(systemName: "person.fill.badge.minus")
        let configuration = UISwipeActionsConfiguration(actions: [deleteAction])
        configuration.performsFirstActionWithFullSwipe = true
        return configuration

}

这就是它的样子:

在此处输入图像描述

这就是我希望它的样子:

在此处输入图像描述

我的有两个问题。

1.没有inset shadow

2.它与我的圆角不对齐cell

知道如何实现吗?

标签: iosswiftuitableview

解决方案


推荐阅读