pragma mark — 添加虚线 –
- (void) addDashed{
//
CAShapeLayer *borderLayer = [CAShapeLayer layer];
borderLayer.bounds = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);//虚线框的大小
borderLayer.position = CGPointMake(CGRectGetMidX(self.bounds),CGRectGetMidY(self.bounds));//虚线框锚点
borderLayer.path = [UIBezierPath bezierPathWithRect:borderLayer.bounds].CGPath;//矩形路径
borderLayer.lineWidth = 1. / [[UIScreen mainScreen] scale];//虚线宽度
//虚线边框
borderLayer.lineDashPattern = @[@5, @5];
//实线边框
borderLayer.fillColor = [UIColor clearColor].CGColor;
borderLayer.strokeColor = [UIColor grayColor].CGColor;
[self.layer addSublayer:borderLayer];
}