Skip to content

Instantly share code, notes, and snippets.

@ro31337
Created October 1, 2014 19:55
Show Gist options
  • Select an option

  • Save ro31337/fae2cc512a560bfa8e37 to your computer and use it in GitHub Desktop.

Select an option

Save ro31337/fae2cc512a560bfa8e37 to your computer and use it in GitHub Desktop.
- (void)drawRect:(CGRect)rect
{
[super drawRect:rect];
CGContextRef context = UIGraphicsGetCurrentContext();
CGRect rect = self.bounds;
UIColor *separatorColor = [UIColor colorWithRed:208.0/255.0 green:208.0/255.0 blue:208.0/255.0 alpha:1.0];
for (int i = 0; i < [columns count]; i++)
{
CGFloat f = [((NSNumber*) [columns objectAtIndex:i]) floatValue];
drawLine(context, CGPointMake(f, 1), CGPointMake(f, rect.size.height), separatorColor.CGColor);
}
}
void drawLine(CGContextRef context, CGPoint startPoint, CGPoint endPoint,
CGColorRef color)
{
CGContextSaveGState(context);
CGContextSetLineCap(context, kCGLineCapSquare);
CGContextSetStrokeColorWithColor(context, color);
CGContextSetLineWidth(context, 1.0);
CGContextMoveToPoint(context, startPoint.x + 0.5, startPoint.y + 0.5);
CGContextAddLineToPoint(context, endPoint.x + 0.5, endPoint.y + 0.5);
CGContextStrokePath(context);
CGContextRestoreGState(context);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment