I'm implementing drag and drop between two UITableView's. When dragging an item over tableView, the tableView automatically displays the space where the new cell will be inserted. I'd like to highlight that space by changing the background color.
Currently, the space for the new cell shows in white. If I change the background color of UITableView, then the space reflects the corresponding background color. However, I do not want to change the background color for the tableView.
Can someone help on how I can achieve it?
Here's a screenshot of the functionality that I'm looking for.
Thanks, Felix.J
Depending on if you're trying to set the background of the future location of the cell or the cell itself, you can alter the background and add effects to the drag cell by calling the dragPreviewParametersForRowAt
function. For example:
func tableView(_ tableView: UITableView, dragPreviewParametersForRowAt indexPath: IndexPath) -> UIDragPreviewParameters? {
let param = UIDragPreviewParameters()
param.backgroundColor = .clear
return param
}
would remove the default white backdrop while a cell is being dragged within a table view.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With