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];
view添加虚线边框
原文:http://www.cnblogs.com/tian-sun/p/5019872.html