Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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