给view button画边框虚线
2019-04-10 本文已影响0人
来敲代码
CAShapeLayer *layer = [[CAShapeLayer alloc] init];
layer.frame = CGRectMake(0, 0 , 140, 50);
layer.backgroundColor = [UIColor clearColor].CGColor;
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:layer.frame cornerRadius:25.0f];
layer.path = path.CGPath;
layer.lineWidth = 1.0f;
layer.lineDashPattern = @[@4, @4];
layer.fillColor = [UIColor clearColor].CGColor;
layer.strokeColor = [UIColor whiteColor].CGColor;
// 这里是需要添加边框的 view or btton
[btton.layer addSublayer:layer];
ViewBorderRadius(NextStep, 25, 1, [UIColor whiteColor]);