CGFloat viewWidth = 200
CGFloat viewHeight = 50
UIButton *view = [[UIButtonalloc]initWithFrame:CGRectMake((screenSize.width - viewWidth)/2, (screenSize.height - viewHeight) / 2, viewWidth, viewHeight)]
CAShapeLayer *borderLayer = [CAShapeLayerlayer]
borderLayer.bounds = CGRectMake(0, 0, viewWidth, viewHeight)
borderLayer.position = CGPointMake(CGRectGetMidX(view.bounds),CGRectGetMidY(view.bounds))
borderLayer.path = [UIBezierPathbezierPathWithRect:borderLayer.bounds].CGPath
borderLayer.lineWidth = 1. / [[UIScreen mainScreen] scale]
//虚线边框
borderLayer.lineDashPattern = @[@5, @5]
//实线边框
// borderLayer.lineDashPattern = nil
borderLayer.fillColor = [UIColorclearColor].CGColor
borderLayer.strokeColor = [UIColorgrayColor].CGColor
[view.layer addSublayer:borderLayer]
[self.viewaddSubview:view]
//画直线
CGMutablePathRef path =CGPathCreateMutable()
CGPathMoveToPoint(path, NULL, startPoint.x , startPoint.y)
CGPathAddLineToPoint(path, NULL, startPoint.x, lineSize.height +startPoint.y)