Skip to content

Instantly share code, notes, and snippets.

@InoruYang
Last active November 12, 2018 03:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save InoruYang/e8827437d8b907c9e9c08183ed6a06a1 to your computer and use it in GitHub Desktop.
Save InoruYang/e8827437d8b907c9e9c08183ed6a06a1 to your computer and use it in GitHub Desktop.
CGFloat lineWith = <#lineWith#>;
CGFloat radius = <#Radius#>;
UIColor *strokeColor = <#strokeColor#>;
CGRect frame = <#viewBound#>;
frame.origin = CGPointMake(lineWith/2, lineWith/2);
frame.size = CGSizeMake(frame.size.width-lineWith, frame.size.height-lineWith);
UIView *borderView = [[UIView alloc] initWithFrame:frame];
borderView.backgroundColor = [UIColor clearColor];
[<#supview#> addSubview:borderView];
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:borderView.bounds cornerRadius: radius];
path.lineWidth = lineWith;
CAShapeLayer *layer = [CAShapeLayer layer];
layer.contentsScale = [UIScreen mainScreen].scale;
layer.frame = borderView.bounds;
layer.path = path.CGPath;
[borderView.layer addSublayer:layer];
layer.strokeColor = strokeColor.CGColor;
layer.fillColor = [UIColor clearColor].CGColor;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment