Created
February 28, 2016 04:13
-
-
Save CaliosD/a1e4078620efb122d91a 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
CAShapeLayer *maskWithHole = [CAShapeLayer layer]; | |
// Both frames are defined in the same coordinate system | |
CGRect biggerRect = CGRectMake(30, 50, 120, 200); | |
CGRect smallerRect = CGRectMake(80, 100, 50, 80); | |
UIBezierPath *maskPath = [UIBezierPath bezierPath]; | |
[maskPath moveToPoint:CGPointMake(CGRectGetMinX(biggerRect), CGRectGetMinY(biggerRect))]; | |
[maskPath addLineToPoint:CGPointMake(CGRectGetMinX(biggerRect), CGRectGetMaxY(biggerRect))]; | |
[maskPath addLineToPoint:CGPointMake(CGRectGetMaxX(biggerRect), CGRectGetMaxY(biggerRect))]; | |
[maskPath addLineToPoint:CGPointMake(CGRectGetMaxX(biggerRect), CGRectGetMinY(biggerRect))]; | |
[maskPath addLineToPoint:CGPointMake(CGRectGetMinX(biggerRect), CGRectGetMinY(biggerRect))]; | |
[maskPath moveToPoint:CGPointMake(CGRectGetMinX(smallerRect), CGRectGetMinY(smallerRect))]; | |
[maskPath addLineToPoint:CGPointMake(CGRectGetMinX(smallerRect), CGRectGetMaxY(smallerRect))]; | |
[maskPath addLineToPoint:CGPointMake(CGRectGetMaxX(smallerRect), CGRectGetMaxY(smallerRect))]; | |
[maskPath addLineToPoint:CGPointMake(CGRectGetMaxX(smallerRect), CGRectGetMinY(smallerRect))]; | |
[maskPath addLineToPoint:CGPointMake(CGRectGetMinX(smallerRect), CGRectGetMinY(smallerRect))]; | |
[maskWithHole setPath:[maskPath CGPath]]; | |
[maskWithHole setFillRule:kCAFillRuleEvenOdd]; | |
[maskWithHole setFillColor:[[UIColor orangeColor] CGColor]]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment