Skip to content

Instantly share code, notes, and snippets.

@rodericj
Created November 20, 2014 02:11
Show Gist options
  • Save rodericj/2a314bb0ee2fc8421dc0 to your computer and use it in GitHub Desktop.
Save rodericj/2a314bb0ee2fc8421dc0 to your computer and use it in GitHub Desktop.
// Create a mask layer and the frame to determine what will be visible in the view.
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
CGRect topMaskRect = CGRectMake(0, 0, 100, 10);
CGRect bottomMaskRect = CGRectMake(0, 33, 100, 10);
// Create a path with the top rect in it.
CGMutablePathRef path = CGPathCreateMutableCopy(CGPathCreateWithRect(topMaskRect, NULL));
// now add the bottom rect to path
CGPathAddRect(path, NULL, bottomMaskRect);
// Set the path to the mask layer.
maskLayer.path = path;
// Release the path since it's not covered by ARC.
CGPathRelease(path);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment