2
使用重叠的不同颜色绘制相同形状时,出现问题。在启用对生成的透明像素进行抗锯齿渗透并导致如this image中的伪像时。她正在绘制一个红色的圆圈,绘制一个蓝色的三角形,然后绘制一个红色的三角形。在使用不同颜色的drawRect中绘制重叠形状时,会启用边缘渗色
此问题可以通过禁用反锯齿解决,但结果是丑陋的锯齿状边缘。
是否有例如解决方案,我可以追溯性地对图像上下文进行反向别名或渲染图像和反锯齿。或其他任何可以帮助我绘制边缘清晰的重叠形状的东西。
这里是重现问题
-(void)drawRect:(CGRect)rect
{
CGContextRef currentContext = UIGraphicsGetCurrentContext();
CGContextClearRect(currentContext, rect);
CGContextSetAllowsAntialiasing(currentContext, YES);
//// Color Declarations
UIColor* color = [UIColor redColor];
UIColor* color2= [UIColor blueColor];
//// Oval Drawing
UIBezierPath* ovalPath = [UIBezierPath bezierPathWithOvalInRect: rect];
[color setFill];
[ovalPath fill];
//// triangle Drawing
UIBezierPath* trianglePath = [UIBezierPath bezierPath];
[trianglePath moveToPoint: CGPointMake(0, 0)];
[trianglePath addLineToPoint: CGPointMake(rect.size.width, rect.size.height)];
[trianglePath addLineToPoint: CGPointMake(0, rect.size.height)];
[trianglePath addLineToPoint: CGPointMake(0, 0)];
[trianglePath closePath];
[color2 setFill];
[trianglePath fill];
[color setFill];
[trianglePath fill];
}
谢谢,我在openGL中设置了相同的图形,它解决了我的问题,即使启用了多重采样,也没有可见的边缘出血。 – TimPelgrim