- (void)drawRect:(CGRect)rect {
CGContextRef line=UIGraphicsGetCurrentContext();
CGContextSetLineWidth(line, self.width);
if (self.ss==YES) {
CGFloat poi[]={5,10,20};
CGContextSetLineDash(line, self.lens, poi, 3);
}
// 通过segmentcontrol控制颜色
switch (self.col) {
case 0:
[[UIColor redColor] setStroke];
break;
case 1:
[[UIColor blueColor] setStroke];
break;
case 2:
[[UIColor greenColor] setStroke];
break;
case 3:
[[UIColor purpleColor] setStroke];
break;
}
for (NSArray *points in self.lines ) {
for (int i=0; i<points.count; i++) {
if (i==0) {
CGContextMoveToPoint(line, [points[0] CGPointValue].x, [points[0] CGPointValue].y);
}
else
CGContextAddLineToPoint(line, [points[i] CGPointValue].x, [points[i] CGPointValue].y);
// NSLog(@"%ld",points.count);
}
}
CGContextDrawPath(line, kCGPathStroke);
}
转载于:https://www.cnblogs.com/lanyisanqqi/p/5146930.html
相关资源:ios-Quartz2D-1.zip