Authored by Justin R. Miller

adapt #231 for configurability

Merge commit 'adf08cbe' into develop
@@ -84,6 +84,9 @@ @@ -84,6 +84,9 @@
84 /** The bounding box of the shape in the current viewport. */ 84 /** The bounding box of the shape in the current viewport. */
85 @property (nonatomic, readonly) CGRect pathBoundingBox; 85 @property (nonatomic, readonly) CGRect pathBoundingBox;
86 86
  87 +/** An additional pixel area around the shape that is applied to touch hit testing events. Defaults to none. */
  88 +@property (nonatomic, assign) CGFloat additionalTouchPadding;
  89 +
87 /** @name Drawing Shapes */ 90 /** @name Drawing Shapes */
88 91
89 /** Move the drawing pen to a projected point. 92 /** Move the drawing pen to a projected point.
@@ -435,11 +435,25 @@ @@ -435,11 +435,25 @@
435 { 435 {
436 // if shape is not filled with a color, do a simple "point on path" test 436 // if shape is not filled with a color, do a simple "point on path" test
437 // 437 //
  438 + if (self.additionalTouchPadding)
  439 + {
  440 + CGPathRef tapTargetPath = CGPathCreateCopyByStrokingPath(shapeLayer.path, nil, fmaxf(self.additionalTouchPadding, shapeLayer.lineWidth), 0, 0, 0);
  441 +
  442 + if (tapTargetPath)
  443 + {
  444 + containsPoint = [[UIBezierPath bezierPathWithCGPath:tapTargetPath] containsPoint:thePoint];
  445 +
  446 + CGPathRelease(tapTargetPath);
  447 + }
  448 + }
  449 + else
  450 + {
438 UIGraphicsBeginImageContext(self.bounds.size); 451 UIGraphicsBeginImageContext(self.bounds.size);
439 CGContextAddPath(UIGraphicsGetCurrentContext(), shapeLayer.path); 452 CGContextAddPath(UIGraphicsGetCurrentContext(), shapeLayer.path);
440 containsPoint = CGContextPathContainsPoint(UIGraphicsGetCurrentContext(), thePoint, kCGPathStroke); 453 containsPoint = CGContextPathContainsPoint(UIGraphicsGetCurrentContext(), thePoint, kCGPathStroke);
441 UIGraphicsEndImageContext(); 454 UIGraphicsEndImageContext();
442 } 455 }
  456 + }
443 else 457 else
444 { 458 {
445 // else do a "path contains point" test 459 // else do a "path contains point" test