CAShapeLayer绘制

CAShapeLayer*fillLayer = [CAShapeLayerlayer];

fillLayer.frame=CGRectMake(p.x, p.y,_dataPointRadius,_dataPointRadius);

fillLayer.bounds=CGRectMake(p.x, p.y,_dataPointRadius,_dataPointRadius);

fillLayer.path= circle.CGPath;

fillLayer.strokeColor=_dataPointColor.CGColor;

fillLayer.fillColor=_dataPointBackgroundColor.CGColor;

fillLayer.lineWidth=1;

fillLayer.lineJoin=kCALineJoinRound;

if(!(i ==0|| i ==7)) {

//画线

CGMutablePathReflinePath =nil;

linePath =CGPathCreateMutable();

fillLayer.lineWidth=1.0f;

fillLayer.lineCap=kCALineCapRound;;

fillLayer.strokeColor= [UIColorwhiteColor].CGColor;

CGPathMoveToPoint(linePath,NULL, p.x, p.y);

CGPathAddLineToPoint(linePath,NULL, p.x,_axisHeight-6);

fillLayer.path= linePath;

//画大圆

CAShapeLayer*solidRun =[CAShapeLayerlayer];

CGMutablePathRefsolidRunPath =CGPathCreateMutable();

solidRun.lineWidth=1.0f;

solidRun.strokeColor= [UIColorwhiteColor].CGColor;

solidRun.fillColor= [UIColorwhiteColor].CGColor;

CGPathAddEllipseInRect(solidRunPath,nil,CGRectMake(p.x-6,_axisHeight-6,12.0f,12.0f));

solidRun.path= solidRunPath;

CGPathRelease(solidRunPath);

[self.layeraddSublayer:solidRun];

//画小圆

CAShapeLayer*solidLine =[CAShapeLayerlayer];

CGMutablePathRefsolidPath =CGPathCreateMutable();

solidLine.lineWidth=1.0f;

solidLine.strokeColor= [UIColorclearColor].CGColor;

if(i ==1)

solidLine.fillColor= [UIColorfsLightPosition1].CGColor;

elseif(i >1&& i <=3)

solidLine.fillColor= [UIColorfsLightPosition2].CGColor;

else

solidLine.fillColor= [UIColorfsLightPosition3].CGColor;

CGPathAddEllipseInRect(solidPath,nil,CGRectMake(p.x-3,_axisHeight-3,6.0f,6.0f));

solidLine.path= solidPath;

CGPathRelease(solidPath);

[self.layeraddSublayer:solidLine];

}

[self.layeraddSublayer:fillLayer];

[self.layersaddObject:fillLayer];

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容