我试图改变垃圾系统图像的颜色,但由于某些原因,它不起作用。
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])
}我需要它,因为我试图给我的删除行动和图像颜色是白色的清晰背景。
发布于 2022-10-26 10:55:27
对于我来说,添加渲染模式作为.alwaysOriginal (note,而不是像我们通常用于着色图像的.alwaysTemplate )起了作用:
action.image = UIImage(systemName: "trash")?.withTintColor(.red, renderingMode: .alwaysOriginal)https://stackoverflow.com/questions/70955225
复制相似问题