views:

98

answers:

1

I have several uiimageviews on my view which the user can drag around. I have them "snapping" to coordinates based on the view... but... I'm wondering if it's possible to snap these to coordinates based on an image.

So I have say one image in the background, a box. When I then drag images around, if they fall inside the box they snap to it. Like I said, I can do this by working out the location in relation to the SCREEN, but not the box.

I'm thinking that I can get the coordinates of the box, then compare to those? Just wondering if there was a better way??

Thanks

A: 

Does the box take up the entire UIImageView? If so you can use CGRectContainsPoint using the UIImageView's frame for the rect and the center of the dragged image as the point.

If the box is only part of the background image, you could get messy and start asking the background for the pixel color at a given location, but I think the way you're doing it now is probably best if that's the case.

David Kanarek