Skip to content

Instantly share code, notes, and snippets.

@iosdevzone
Last active August 29, 2015 14:16
Show Gist options
  • Save iosdevzone/7152d3d6212c2b71761e to your computer and use it in GitHub Desktop.
Save iosdevzone/7152d3d6212c2b71761e to your computer and use it in GitHub Desktop.
- (void)drawRect:(CGRect)rect {
[[UIColor lightGrayColor] setFill];
[[UIColor darkGrayColor] setStroke];
UIBezierPath *path = [[UIBezierPath alloc] init];
CGPoint touchPoint = [self.lastTouch locationInView:self];
CGFloat y0 = self.bounds.origin.y;
CGFloat weight = 0.75; // Vary from 0 - 1. Values closed to 1 are more pointy.
CGFloat y1 = y0 + (touchPoint.y - y0) * weight; // between top of screen and touch
CGFloat y2 = touchPoint.y;
CGFloat y4 = CGRectGetMaxY(self.bounds);
CGFloat y3 = y4 - (y4 - y2) * weight; // between touch point and bottom of screen
CGFloat x0 = self.bounds.origin.y;
CGFloat x1 = touchPoint.x;
[path moveToPoint:CGPointZero];
[path addCurveToPoint:touchPoint controlPoint1:CGPointMake(x0, y1) controlPoint2:CGPointMake(x1, y1)];
[path addCurveToPoint:CGPointMake(x0, y4) controlPoint1:CGPointMake(x1, y3) controlPoint2:CGPointMake(x0, y3)];
[path closePath];
[path fill];
[path stroke];
}
@iosdevzone
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment