I was wondering if there is a simple way to find out if a certain point is in a certain CGRect?
I have this to get the position of where the user touched the screen:
UITouch *touch = [touches anyObject];
CGPoint currentPosition = [touch locationInView:self.view];
No I would like to find out if this point is in the following rect:
CGRect aFrame = CGRectMake(0, 100, 320, 200);
The following does obviously not work:
if (currentPosition = aFrame) {//do something}
I'd be grateful for any help. Thanks a lot!
Use CGRectContainsPoint
function to determine if point lies inside a rectangle:
if (CGRectContainsPoint(aFrame, currentPosition))
// Do something
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With