Created
September 7, 2016 01:47
-
-
Save mactive/69004e8595e80422834b374f7754d6f7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
-(void)makeMaskWithFrame:(CGRect)frame | |
{ | |
// Create a mask layer and the frame to determine what will be visible in the view. | |
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init]; | |
// CGContextFillEllipseInRect(); | |
CGRect maskRect = CGRectMake(0, 0, frame.size.width, frame.size.height); | |
// Create a path with the rectangle in it. | |
CGPathRef path = CGPathCreateWithEllipseInRect(maskRect, NULL); | |
// Set the path to the mask layer. | |
maskLayer.path = path; | |
// Release the path since it's not covered by ARC. | |
CGPathRelease(path); | |
// Set the mask of the view. | |
_mainView.layer.mask = maskLayer; | |
_mainView.layer.borderWidth = 2.0f; | |
_mainView.layer.borderColor = [UIColor blueColor].CGColor; | |
// 方向 | |
// 尝试用去 圆角矩形去实现 一个圆形 borderRadius 而不是 mask了 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment