Created
October 30, 2013 12:32
-
-
Save ferbass/7231889 to your computer and use it in GitHub Desktop.
Objective-C ZigZag line with CoreGraphics
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
- (void)drawRect:(CGRect)rect | |
{ | |
CGContextRef context = UIGraphicsGetCurrentContext(); | |
CGContextSetStrokeColorWithColor(context, [[UIColor colorWithRed:241.0/255.0 green:241.0/255.0 blue:238.0/255.0 alpha:1] CGColor]); | |
CGContextSetLineWidth(context, 0.6); | |
CGContextMoveToPoint(context, CGRectGetMinX(rect), CGRectGetMaxY(rect) - 5); | |
CGContextSetShouldAntialias(context, YES); | |
for (int i = 0; i < 320; i++) { | |
float x = (CGRectGetMinX(rect) + 7) * i; | |
float y = CGRectGetMaxY(rect) - 5; | |
CGContextAddLineToPoint(context, x, y); | |
CGContextAddLineToPoint(context, x + 1, y); | |
CGContextAddLineToPoint(context, x + 4, CGRectGetMaxY(rect)); | |
CGContextSetShouldAntialias(context, NO); | |
} | |
CGContextStrokePath(context); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment