CrazyDev CrazyDev - 11 months ago 82
iOS Question

IOS: verify if a point is inside a rect

Is there a way to verify if a

is inside a specific
At example: I'm dragging an
and I want to verify if its central point
is inside another
how can I do?

Answer Source

See CGRectContainsPoint() in the documentation.

bool CGRectContainsPoint(CGRect rect, CGPoint point);


  • rect The rectangle to examine.
  • point The point to examine. Return Value true if the rectangle is not null or empty and the point is located within the rectangle; otherwise, false.

A point is considered inside the rectangle if its coordinates lie inside the rectangle or on the minimum X or minimum Y edge.