0

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

4

1 回答 1

0

盒子是否占据了整个 UIImageView?如果是这样,您可以使用CGRectContainsPointUIImageView 的框架作为矩形和拖动图像的中心作为点。

如果该框只是背景图像的一部分,您可能会变得混乱并开始向背景询问给定位置的像素颜色,但我认为如果是这种情况,您现在的做法可能是最好的。

于 2010-01-21T23:09:20.187 回答