美文网首页
CAShapeLayer绘制

CAShapeLayer绘制

作者: ShiyongTan | 来源:发表于2016-03-31 16:18 被阅读1426次

    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];

    相关文章

      网友评论

          本文标题:CAShapeLayer绘制

          本文链接:https://www.haomeiwen.com/subject/vdwelttx.html