-
StackOverflow 文档
-
iOS 教程
-
CAShapeLayer
-
绘制矩形
CAShapeLayer *mask = [[CAShapeLayer alloc] init];
mask.frame = CGRectMake(50, 50, 100, 100);
CGFloat width = 100;
CGFloat height = 100;
CGMutablePathRef path = CGPathCreateMutable();
CGPathMoveToPoint(path, nil, 30, 30);
CGPathAddLineToPoint(path, nil, width, 30);
CGPathAddLineToPoint(path, nil, width, height);
CGPathAddLineToPoint(path, nil,30, height);
CGPathAddLineToPoint(path, nil, 30, 30);
CGPathCloseSubpath(path);
mask.path = path;
CGPathRelease(path);
self.view.layer.mask = mask;