Skip to content

Instantly share code, notes, and snippets.

@jesseXu
Created August 30, 2016 23:51
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 jesseXu/d69fb7d256b26678dfeb13f337956645 to your computer and use it in GitHub Desktop.
Save jesseXu/d69fb7d256b26678dfeb13f337956645 to your computer and use it in GitHub Desktop.
Mask View
UIView *overlay = [[UIView alloc] initWithFrame:window.bounds];
overlay.backgroundColor = [UIColor colorWithHex:0x3ED4B6];
UIBezierPath *path = [UIBezierPath bezierPathWithRect:overlay.bounds];
// transparent circle rect
CGRect rect = CGRectMake(CGRectGetMidX(overlay.bounds) - 41, CGRectGetMidY(overlay.bounds) - 41, 82, 82);
[path appendPath:[UIBezierPath bezierPathWithOvalInRect:rect]];
CAShapeLayer *shapeLayer = [CAShapeLayer layer];
shapeLayer.frame = overlay.bounds;
shapeLayer.fillColor = [UIColor blackColor].CGColor;
shapeLayer.fillRule = kCAFillRuleEvenOdd;
shapeLayer.path = path.CGPath;
overlay.layer.mask = shapeLayer;
[window addSubview:overlay];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment