IOS画虚线

画虚线


  UIBezierPath *linePath1 = [UIBezierPath bezierPath];

    {

        [linePath1 moveToPoint:CGPointMake(0, 0)];

        [linePath1 addLineToPoint:CGPointMake(_lineOne.width, 0)];

    }

    

    CAShapeLayer *layer1 = [CAShapeLayer layer];

    {

        UIColor *drawColor = RGBColor(9, 150, 255);

        layer1.path = linePath1.CGPath;

        layer1.strokeColor = drawColor.CGColor;

        layer1.fillColor = [UIColor clearColor].CGColor;

        layer1.lineWidth = 1;

        [layer1 setLineDashPattern:

//每段线的宽度

         [NSArray arrayWithObjects:[NSNumber numberWithInt:1],

//线与线的间隔

          [NSNumber numberWithInt:2],nil]];

        layer1.lineCap = @"round";

        [_lineOne.layer addSublayer:layer1];

    }

    


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