I have tried checking the CGRect:
CGFloat imageX1 = imageView.frame.origin.x;
CGFloat imageY1 = imageView.frame.origin.y;
CGFloat imageX2 = imageView.frame.origin.x + imageView.frame.size.width;
CGFloat imageY2 = imageView.frame.origin.y + imageView.frame.size.height;
//NSLog(@"(%f, %f) - (%f, %f)", imageX1, imageY1, imageX2, imageY2);
if(imageX1 < touchedX && touchedX < imageX2 &&
imageY1 < touchedY && touchedY < imageY2){ }
And then I know that this type of checking only works when the UIImageView has not been rotated/scaled.
I have tried CGRectApplyAffineTransform(imageView.frame, imageView.transform);, but It creates a smallest rect for the transformed UIImageView.
So let say you have an UIImageView rotated 45 degrees, and scaled to 1.5. Now when you touch a couple pixels outside the UIImageView, it still considers the touch point is inside the UIImageView Rect, but It’s not. The UIImageView is rotated and scaled, but the CGRect is still the original one.
Anyone knows about how to deal with this? I am pretty new to graphic stuff. Anything would help. Thanks!
try this