Skip to content

Instantly share code, notes, and snippets.

@funkydevil
Created March 26, 2015 08:27
Show Gist options
  • Save funkydevil/bfd78e167f601037f909 to your computer and use it in GitHub Desktop.
Save funkydevil/bfd78e167f601037f909 to your computer and use it in GitHub Desktop.
Draw a line in UIView
- (void)drawRect:(CGRect)rect {
[super drawRect:rect];
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor);
// Draw them with a 2.0 stroke width so they are a bit more visible.
CGContextSetLineWidth(context, 2.0f);
CGContextMoveToPoint(context, 0.0f, 0.0f); //start at this point
CGContextAddLineToPoint(context, 20.0f, 20.0f); //draw to this point
// and now draw the Path!
CGContextStrokePath(context);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment