0

My question related to: How to achieve transparent background or rounded corners when dragging a UICollectionViewCell

But how can I do this with SwiftUI?

Just Alex
  • 183
  • 1
  • 12

2 Answers2

2

From iOS 15, you can do this:

DraggedView()
    .contentShape([.dragPreview], RoundedRectangle(cornerRadius: 20))
    .onDrag(...)
benmeiz
  • 21
  • 3
0

I found a solution there: ContextMenu on a rounded LinearGradient produces sharp edges in SwiftUI

So, when I used contentShape with onDrag it works.

Just Alex
  • 183
  • 1
  • 12
  • 1
    Does not work for me. I still see a semi-transparent background in the corners while dragging, even after adding `contentShape` with a `RoundedRectangle`. Could you maybe post your working code? – viedev May 03 '22 at 09:28