- (void)drawRect:(CGRect)rect {
[super drawRect:rect];
[[UIColor whiteColor] set];
CGFloat radius = rect.size.width / 2;
// 绘制路径
//---------------------------------------------------------------------------------------------------------------------
UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(radius, radius) radius:radius startAngle:M_PI endAngle:0 clockwise:YES];
[path moveToPoint:CGPointMake(0, radius)];
[path addQuadCurveToPoint:CGPointMake(radius, rect.size.height) controlPoint:CGPointMake(0, radius * 1.5)];
[path addQuadCurveToPoint:CGPointMake(2 * radius, radius) controlPoint:CGPointMake(2 * radius, radius * 1.5)];
// --------------------------------------------------------------------------------------------------------------------
[path fill];
[self.image drawAsPatternInRect:rect];
CAShapeLayer *shapLayer = [CAShapeLayer layer];
shapLayer.path = path.CGPath;
self.layer.mask = shapLayer;
}
网友评论