iOS画虚线边框

这是给self.view画一个类似self.layer.border的边框, 是虚线~

在网上找的例子


CAShapeLayer *border = [CAShapeLayer layer];

border.strokeColor = SLColorLine.CGColor;

border.fillColor = nil;

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

border.frame = self.bounds;

border.lineWidth = 1.f;

border.lineCap = @"square";

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

[self.layer addSublayer:border];

你可能感兴趣的:(OC-类,Object-C开发)