使用CAShapeLayer给view花虚线的边框

来源:互联网 发布:淘宝客服三班倒时间 编辑:程序博客网 时间:2024/06/14 05:27

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

原创粉丝点击