TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

OnDrag Preview not centering on selected drag item but on parent view

Forums > SwiftUI

Hi All,

Back again with another question - things are moving on, at least.

Slowly figuring out Drag n Drop but have run into a problem. When I select my Drag target the view I'm given to drag around is the entirety of the top level view; it does, however, center on the selected target.

So I've replaced that with a Preview item instead which works but it now centres that on the parent view, as can be seen in the image below. I've highlighted the drag target with the red circle and the green blob in the middle is the preview it's given me. I tried using offset but that shifts the rectangle within the centred frame itself.


Anyone got any suggestions how I can get around that?

Thanks in advance,



Hacking with Swift is sponsored by String Catalog.

SPONSORED Get accurate app localizations in minutes using AI. Choose your languages & receive translations for 40+ markets!

Localize My App

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.