iOS 中添加虚线框

(```)

  • (void)backGroundViewLine:(CGFloat)lineWidth lineColor:(UIColor *)lineColor {
    CAShapeLayer *border = [CAShapeLayer layer];
    border.strokeColor = lineColor.CGColor;
    border.cornerRadius = 4.0;
    border.fillColor = nil;
    border.path = [UIBezierPath bezierPathWithRect:self.backGroundView.bounds].CGPath;
    border.frame = self.backGroundView.bounds;
    border.lineWidth = lineWidth;
    border.lineDashPattern = @[@(1), @(2)];
    [self.backGroundView.layer addSublayer:border];
    }
    (```)

你可能感兴趣的:(iOS 中添加虚线框)