为一个view加虚线边框

CAShapeLayer *border = [CAShapeLayer layer];

    border.strokeColor = [UIColor redColor].CGColor;//[UIColor colorWithRed:67/255.0f green:37/255.0f blue:83/255.0f alpha:1].CGColor;

    border.fillColor = nil;

    border.lineDashPattern = @[@20,@5];//@[@4, @2];

    border.lineWidth = 3;

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

    border.frame = textView.bounds;

    [textView.layer addSublayer:border];

你可能感兴趣的:(ios)