_btnView.layer.cornerRadius = 6.0;
CAShapeLayer *borderLayer = [CAShapeLayer layer];
borderLayer.bounds = CGRectMake(0, 0, _btnView.width, _btnView.height);
borderLayer.position = CGPointMake(CGRectGetMidX(_btnView.bounds), CGRectGetMidY(_btnView.bounds));
borderLayer.path = [UIBezierPath bezierPathWithRoundedRect:borderLayer.bounds cornerRadius:6.0].CGPath;
borderLayer.lineWidth = 9 / [[UIScreen mainScreen] scale];
//虚线边框---小边框的长度
borderLayer.lineDashPattern = @[@6, @3];//前边是虚线的长度,后边是虚线之间空隙的长度
borderLayer.lineDashPhase = 0.1;
//实线边框
borderLayer.fillColor = [UIColor clearColor].CGColor;
borderLayer.strokeColor = [UIColor redColor].CGColor;
CAShapeLayer *borderLayer = [CAShapeLayer layer];
borderLayer.bounds = CGRectMake(0, 0, _btnView.width, _btnView.height);
borderLayer.position = CGPointMake(CGRectGetMidX(_btnView.bounds), CGRectGetMidY(_btnView.bounds));
borderLayer.path = [UIBezierPath bezierPathWithRoundedRect:borderLayer.bounds cornerRadius:6.0].CGPath;
borderLayer.lineWidth = 9 / [[UIScreen mainScreen] scale];
//虚线边框---小边框的长度
borderLayer.lineDashPattern = @[@6, @3];//前边是虚线的长度,后边是虚线之间空隙的长度
borderLayer.lineDashPhase = 0.1;
//实线边框
borderLayer.fillColor = [UIColor clearColor].CGColor;
borderLayer.strokeColor = [UIColor redColor].CGColor;
[
_btnView
.
layer
addSublayer
:borderLayer];