Detect if CGPoint within polygon

You can create a CG(Mutable)PathRef (or a UIBezierPath that wraps a CGPathRef) from your points and use the CGPathContainsPoint function to check if a point is inside that path. If you use UIBezierPath, you could also use the containsPoint: method.


For that you need to write one method that implements a point inside polygon algorithm.

This method will take an array with N points (the polygon) as an argument and one specific point. It should return true if the point is inside the polygon and false if not.

See this great answer on S.O.