快速添加图标和文本到滑动单元格操作

Ali*_*RAL 3 uitableview ios swift

我尝试将图标添加到滑动操作,但没有找到任何解决方案。有人说“‘trailingSwipeActionsConfigurationForRowAt’不可能”。这是真的还是有什么解决办法?谢谢您的回复。

在此输入图像描述

小智 5

尝试这样

func tableView(_ tableView: UITableView,
                       trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration?
{
      let deleteAction = UIContextualAction(style: .normal, title:  "", handler: { (ac:UIContextualAction, view:UIView, success:(Bool) -> Void) in
                // Your Call Here
                success(true)
      })
      deleteAction.image = UIImage(named: "Trash")
      deleteAction.backgroundColor = COLOR_ORANGE

      return UISwipeActionsConfiguration(actions: [deleteAction])
}
Run Code Online (Sandbox Code Playgroud)