Last active
November 12, 2018 03:18
-
-
Save InoruYang/e8827437d8b907c9e9c08183ed6a06a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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