@Heyya's circle is a real drag....
However, my code does not achieve the second functionality:
when I drag an already added MyCircle(), its position does not change.
Instead, a new MyCircle() is added
Consider adding an array of circle objects to your TableView
. As you tap into the TableView
, grab the coordinates of the tap. Run through each circle object in the array to see if if there is a circle under the tap's coordinates. If it IS UNDER the tap coordinates, you can then update that circle's coordinates to match the user's finger drag.
If there's nothing under the tap gesture, this may tell your app to create a NEW circle object, and add it to the TableView
's array of circles.
The Other Paul
Paul Hagerty is another excellent SwiftUI instructor who posts lessons on the YouTube. He is a professor at Standford University and teaches iOS programming to engineering students. Starting with Lesson 10, he creates an app titled "Emoji Art" designed for young children to add emoji (animals, birds, clowns, vehicles, etc) to a colorful background.
This app teaches dragging techniques, including drag-n-drop. I highly recommend you start with Lesson 10.
See-> Emoji Art
Keep Coding