画矩形虚线

CAShapeLayer *border = [CAShapeLayer layer];

//线的颜色

border.strokeColor = LineColor.CGColor;

border.fillColor = nil;

border.path = [UIBezierPath bezierPathWithRect:_dotLineView.bounds].CGPath;

border.lineWidth = 1.f;

border.lineCap = @"square";

//4是线的宽度  3是每条线的间距

border.lineDashPattern = @[@4, @3];

[_dotLineView.layer addSublayer:border];

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