Created
January 28, 2014 22:59
-
-
Save 0xMarK/8678441 to your computer and use it in GitHub Desktop.
A complicated mask with UIBezierPath
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
CAShapeLayer *maskLayer = [CAShapeLayer layer]; | |
maskLayer.frame = CGRectMake(0, 0, self.poster.frame.size.width, self.poster.frame.size.height); | |
UIBezierPath* bezierPath = [UIBezierPath bezierPath]; | |
[bezierPath moveToPoint:CGPointMake(0.0, 5.0)]; | |
[bezierPath addArcWithCenter:CGPointMake(5.0, 5.0) radius:5.0 startAngle:DEGREES_TO_RADIANS(180) endAngle:DEGREES_TO_RADIANS(-90) clockwise:YES]; | |
[bezierPath addLineToPoint:CGPointMake(107.0, 0.0)]; | |
[bezierPath addArcWithCenter:CGPointMake(107.0, 5.0) radius:5.0 startAngle:DEGREES_TO_RADIANS(-90) endAngle:DEGREES_TO_RADIANS(0) clockwise:YES]; | |
[bezierPath addLineToPoint:CGPointMake(112.0, 89.0)]; | |
[bezierPath addArcWithCenter:CGPointMake(107.0, 89.0) radius:5.0 startAngle:DEGREES_TO_RADIANS(0) endAngle:DEGREES_TO_RADIANS(90) clockwise:YES]; | |
[bezierPath addLineToPoint:CGPointMake(44.0, 94.0)]; | |
[bezierPath addArcWithCenter:CGPointMake(44.0, 89.0) radius:5.0 startAngle:DEGREES_TO_RADIANS(90) endAngle:DEGREES_TO_RADIANS(180) clockwise:YES]; | |
[bezierPath addLineToPoint:CGPointMake(39.0, 83.0)]; | |
[bezierPath addArcWithCenter:CGPointMake(34.0, 83.0) radius:5.0 startAngle:DEGREES_TO_RADIANS(0) endAngle:DEGREES_TO_RADIANS(-90) clockwise:NO]; | |
[bezierPath addLineToPoint:CGPointMake(5.0, 78.0)]; | |
[bezierPath addArcWithCenter:CGPointMake(5.0, 73.0) radius:5.0 startAngle:DEGREES_TO_RADIANS(90) endAngle:DEGREES_TO_RADIANS(180) clockwise:YES]; | |
[bezierPath closePath]; | |
maskLayer.path = bezierPath.CGPath; | |
self.poster.layer.mask = maskLayer; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment