Skip to content

Instantly share code, notes, and snippets.

@acalism
Last active August 27, 2015 13:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acalism/254acd16e0f41ea36c78 to your computer and use it in GitHub Desktop.
Save acalism/254acd16e0f41ea36c78 to your computer and use it in GitHub Desktop.
// You'll also need the QuartzCore framework added to the project
#import <QuartzCore/QuartzCore.h>
int x = 0; int y = 0;
int toX = 30; int toY = 40;
CGMutablePathRef linePath = CGPathCreateMutable();
CGPathMoveToPoint(linePath, NULL, x, y);
CGPathAddLineToPoint(linePath, NULL, toX, toY);
CAShapeLayer *lineShape = [CAShapeLayer layer];
lineShape.lineWidth = 4.0f;
lineShape.lineCap = kCALineCapRound;;
lineShape.strokeColor = [[UIColor blackColor] CGColor];
lineShape.path = linePath;
CGPathRelease(linePath);
[self.layer addSublayer:lineShape];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment