给view button画边框虚线

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

你可能感兴趣的:(给view button画边框虚线)