我正在尝试更改垃圾系统图像的颜色,但由于某种原因它不起作用。
func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
let deleteAction = UIContextualAction(style: .normal, title: nil) { (ac: UIContextualAction, view: UIView, success: (Bool) -> Void) in
let cell = tableView.cellForRow(at: indexPath) as? HeroTableViewCell
if let _ = cell?.nameLabel.text {
self.deleteHeroName(index: indexPath)
}
success(true)
}
deleteAction.image = UIImage(systemName: "trash")?.withTintColor(.red)
return UISwipeActionsConfiguration(actions: [deleteAction])
}
我需要它,因为我试图为我的删除操作提供清晰的背景,并且图像颜色为白色。