1

I would like the user to be able to trace a predefined CGPath/UIBezierpath with their finger and get a warning if they go outside of the lines (say the line thickness is e.g. 30px to make it easier).

How would I perform such a check based on the knowledge that the amount of events returned by the touch event methods vary depending on the finger's movement?

ESoft
  • 852
  • 1
  • 8
  • 21

1 Answers1

3

Use CGPathCreateCopyByStrokingPath to create a path that outlines the stroked path. Then use CGPathContainsPoint to test whether the touched point is inside that outline.

rob mayoff
  • 375,296
  • 67
  • 796
  • 848
  • Thank. I don't think that's going to work though. If path A has a curve containing 20 points, and path B is a straight line containing the starting point and the ending point of A, then B's points will return a positive response even though these paths do not overlap. – ESoft Apr 21 '12 at 17:27
  • That is a completely different problem that what you described in your original question. – rob mayoff Apr 21 '12 at 17:51