CustomBorderView.m 871 B

123456789101112131415161718192021222324252627282930
  1. //
  2. // CustomBorderView.m
  3. // IBOSS-HJ
  4. //
  5. // Created by 关宏厚 on 2021/1/5.
  6. // Copyright © 2021 elongtian. All rights reserved.
  7. //
  8. #import "CustomBorderView.h"
  9. @implementation CustomBorderView
  10. -(void) drawBoardLine:(double)width cornerRadius:(double)cornerRadius color:(UIColor*)color
  11. {
  12. self.layer.cornerRadius = cornerRadius;
  13. CAShapeLayer *borderLayer = [CAShapeLayer layer];
  14. borderLayer.bounds = self.bounds;
  15. borderLayer.position = CGPointMake(CGRectGetMidX(self.bounds), CGRectGetMidY(self.bounds));
  16. borderLayer.path = [UIBezierPath bezierPathWithRoundedRect:borderLayer.bounds cornerRadius:cornerRadius].CGPath;
  17. borderLayer.lineWidth = width;
  18. //实线边框
  19. borderLayer.fillColor = [UIColor clearColor].CGColor;
  20. borderLayer.strokeColor = color.CGColor;
  21. [ self. layer addSublayer :borderLayer];
  22. }
  23. @end