Either will work, but each have pros and cons. Specifically:
- Single
UIView
: This approach would require you to create aCALayer
for each shape and then do your own hit-testing and finger-dragging when the shape is moved. This approach will perform much better if you have many shapes (be sure to use an indexed lookup to do hit testing rather than an O(N) search) sinceCALayer
s are lightweight.- Do not take the approach o drawing the shapes in their current location in a single
UIView
via a single call todrawRect:
. This will perform extremely poorly, especially when you are move the shapes during a drag, and as you indicate, is very complicated to implement well
- Do not take the approach o drawing the shapes in their current location in a single
- One
UIView
Per Shape: This approach is very easy to program, as you don't have to do the hit-testing and the touch get's sent to the shape being touched. This approach will perform well if you have a few shapes (<30, in my experience). If you have a large number of shapes, you start to see issues with frame rate.