Created
June 25, 2015 07:19
-
-
Save nestserau/f46a8abbc69a9697180d to your computer and use it in GitHub Desktop.
Draw line in UIView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* http://stackoverflow.com/questions/3128752/draw-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