I am using CGRectContainsPoint
to find whether a point is inside a rect but it always returns false.
If I am wrong please correct me and help me understand whether the point is inside the CGRect
. Here is my code:
BOOL isObjectInside = false;
CGPoint serverPoint = CGPointMake(78,157);
CGRect frame = CGRectMake(31, 207, 98, 28);
if(CGRectContainsPoint(frame, serverPoint))
{
isObjectInside = true;
}
else
{
isObjectInside = false;
}
Here is a rendering of your view hierarchy:
Note that the red dot is not inside the yellow square.
Therefore, it's expected that CGRectContainsPoint
would return NO
/ false
.