Created
August 30, 2016 23:51
-
-
Save jesseXu/d69fb7d256b26678dfeb13f337956645 to your computer and use it in GitHub Desktop.
Mask View
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
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