Ios 如何将UITableView的颜色设置为DeletePlaceHolderCell

Ios 如何将UITableView的颜色设置为DeletePlaceHolderCell,ios,swift,uitableview,uicolor,Ios,Swift,Uitableview,Uicolor,我将UITableView的backgroundView设置为UIImageView。UIImageView使用具有渐变图案的图像 let imageView = UIImageView.init(frame: tableView.frame) imageView.image = UIImage.init(named: "background") tableView.backgroundView = imageView 删除行时,表会自动插入一个白色行。当我用Xcode暂停应用程序以查看绘制的

我将UITableView的backgroundView设置为UIImageView。UIImageView使用具有渐变图案的图像

let imageView = UIImageView.init(frame: tableView.frame)
imageView.image = UIImage.init(named: "background")
tableView.backgroundView = imageView
删除行时,表会自动插入一个白色行。当我用Xcode暂停应用程序以查看绘制的组件时,它显示它是一个_uiswittodeleteplaceholdercell

如何使_uiswiptodeleteplaceholdercell使用清晰的背景色

我曾尝试将tableview中的所有组件设置为使用清晰的颜色,但这似乎不起作用

view.backgroundColor = UIColor.clear
tableView.backgroundColor = UIColor.clear
tableView.separatorColor = UIColor.clear
tableView.sectionIndexColor = UIColor.clear
tableView.sectionIndexBackgroundColor = UIColor.clear
tableView.sectionIndexTrackingBackgroundColor = UIColor.clear
以下是我如何删除:

override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
    if editingStyle == .delete {
        // Delete the row from the data source
        self.budget = budget.removingTransaction(at: indexPath.row-1)
        tableView.deleteRows(at: [indexPath], with: .none)
    }
}


我希望这是因为删除您的行后更新了表。 请尝试以下代码:-

override func tableView(_ tableView: UITableView, commit editingStyle: 
UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
    if editingStyle == .delete {
        // Delete the row from the data source
        self.budget = budget.removingTransaction(at: indexPath.row-1)
        tableView.beginUpdates()
        tableView.deleteRows(at: [indexPath], with: .none)
        tableView.endUpdates()
    }
}
我希望它能帮助你,
谢谢。

请分享与删除tableview单元相关的代码。问题是这不是您的类。没有办法搞乱它。如果你真的把它搞砸了,那么当你试图提交应用程序时,你很可能会被激怒。这似乎是一个很好的向苹果提交增强请求的用例,但在他们给你一个正式的方式之前,你可能只是被卡住了。不知道为什么你删除一个单元格时会插入一个单元格。如果只是在动画期间,我想可能是因为
表视图的默认颜色。backgroundColor
为白色,请将其设置为与单元格颜色匹配。@matt我不想直接修改单元格,我只是想找到一种方法使其清晰。也许通过配置tableview来解释为什么。@user1046037我已经将backgroundColor设置为ClearThank。这并没有解决问题。不过我已经提交了一份bug报告
 func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
    if editingStyle == .delete {
        dataSource.remove(at: indexPath.row)
        tableView.deleteRows(at: [indexPath], with: .automatic)
        clearWhiteBackgroundWhenDelete()
    }
}

func clearWhiteBackgroundWhenDelete() {
    if let whiteBackgroudViewClass = NSClassFromString("_UISwipeToDeletePlaceholderCell") {
       _ = tableView.subviews.map { if $0.isKind(of: whiteBackgroudViewClass) { $0.backgroundColor = .clear } }
    }
}