【发布时间】:2011-07-29 00:14:43
【问题描述】:
我正在尝试绘制一个被椭圆挖空的 320x480 矩形。 想象一下画一个填充的矩形,在矩形上画一个填充的椭圆,然后从矩形中删除椭圆,留下一个透明的洞。
- (void)drawRect:(CGRect)rect
{
// Drawing code.
CGContextRef context = UIGraphicsGetCurrentContext();
// Set color to red
CGContextSetRGBFillColor(context, 1.0, 0.0, 0.0, 1.0);
// Add rectange
CGContextAddRect(context, rect);
// Fill rectange
CGContextFillRect(context, rect);
// Create a elipse to be removed from rectange
CGPathRef circlePath = CGPathCreateMutable();
CGPathAddEllipseInRect(circlePath , NULL , elipseRect);
CGContextAddPath(context, circlePath);
CGContextSetRGBFillColor(context, 1.0, 1.0, 0.0, 1.0);
CGContextFillPath(context);
// clip elipse... (DO NOT WORK)
CGContextEOClip(context);
}
当我试图从矩形中删除椭圆时,它不起作用。
有人有解决办法吗?
【问题讨论】:
标签: iphone core-graphics quartz-graphics