UIBezierPath 画线

CAShapeLayer *shapeLayer = [CAShapeLayer layer];

UIBezierPath *path = [UIBezierPath bezierPath];

[path moveToPoint:CGPointMake(20,UULabelHeight+i*levelHeight)];

[path addLineToPoint:CGPointMake(self.frame.size.width,UULabelHeight+i*levelHeight)];

[path closePath];

shapeLayer.path = path.CGPath;

shapeLayer.strokeColor = self.xlineColor ? self.xlineColor.CGColor :[[[UIColor blackColor] colorWithAlphaComponent:0.1] CGColor];

shapeLayer.fillColor = [[UIColor whiteColor] CGColor];

shapeLayer.lineWidth = 1;

[self.layer insertSublayer:shapeLayer atIndex:0];

CGFloat curMark_Y = levelHeight * i;



//底部实线

CAShapeLayer *xLayer = [CAShapeLayer layer];

[self.xPath moveToPoint:CGPointMake(30, UULabelHeight+ 5*levelHeight)];

[self.xPath addLineToPoint:CGPointMake(self.frame.size.width,UULabelHeight+ 5*levelHeight)];

xLayer.lineWidth = 1;

xLayer.strokeColor = [UIColor colorWithHex:@"#959595"].CGColor;

xLayer.path = self.xPath.CGPath;

[self.layer addSublayer:xLayer];

[self.xAxisPath moveToPoint:CGPointMake(self.startPoint.x, chartCavanHeight - i * levelHeight + 25)];

[self.xAxisPath addLineToPoint:CGPointMake(self.startPoint.x + self.frame.size.width, chartCavanHeight - i * levelHeight + 25)];

CAShapeLayer *xAxisLayer = [CAShapeLayer layer];

[xAxisLayer setLineDashPattern:[NSArray arrayWithObjects:[NSNumber numberWithInt:2], [NSNumber numberWithInt:2], nil]];

xAxisLayer.lineWidth = 0.3;

xAxisLayer.strokeColor = [UIColor blackColor].CGColor;

xAxisLayer.path = self.xAxisPath.CGPath;

[self.layer addSublayer:xAxisLayer];

你可能感兴趣的:(UIBezierPath 画线)