79654947

Date: 2025-06-05 17:26:42
Score: 1
Natty:
Report link

What’s happening is that when you drag a cell, you set up an oval-shaped preview by implementing:

func collectionView(_ collectionView: UICollectionView, dragPreviewParametersForItemAt indexPath: IndexPath) -> UIDragPreviewParameters?

But once you let go and the drop animation kicks in, UIKit goes back to a plain rectangular preview (with the default shadow and background) unless you also tell it otherwise. To keep that oval look during the drop animation, you also need to add:

func collectionView(_ collectionView: UICollectionView, dropPreviewParametersForItemAt indexPath: IndexPath) -> UIDragPreviewParameters?

and return the same oval-shaped parameters. If you don’t, UIKit just uses the rectangular snapshot, and you’ll see the unwanted shadow and background after dropping.

Result

Six white, pill-shaped cells on a light gray background display the top-left pill being lifted and dragged to a new position while preserving its rounded shape

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Starts with a question (0.5): What
  • Low reputation (0.5):
Posted by: olejiksa