How can I determine if two uiviewimages intersect. I want to do an auto snap feature. When the small image intersects with the big image or close to it (Lets says the distance<=x), I want the small image automatically snap(connect) to the big image at the point where they intersect.
Intersection Of Two UIViewImages
2.4k Views Asked by Asım Sinan Yüksel At
3
The previous two posters have been on the right track with
CGRectIntersectsRect
.Basically what this says that if the two images are intersecting, the small image frame snap to the larger image over 0.5 seconds. You don't have to animate it though; you could just make it instantaneous by removing all code except for
smallImage.frame = largeImage.frame;
. However, I recommend the animation way. Hope this helps.-------EDIT--------
You could use the code:
Hope this fixed your problem. Remember to up vote and pick as the answer if this helped.
-------EDIT--------- One last thing. I said that the "30" in
CGAffineTransformMakeRotation(30)
stood for 30 degrees, but that is incorrect. The CGAffineTransformMakeRotation function takes its parameter in radians, so if you wanted 30 degrees you could do this: