【发布时间】:2014-09-20 15:50:06
【问题描述】:
我在 UIView drawRect 函数中绘制一个形状,该函数涉及剪切路径,然后在后面添加彩色块,以便颜色具有剪切路径的形状。但是,由于某种原因,路径的线条并不顺畅;如果抗锯齿不能正常工作。
CGContextSetStrokeColorWithColor(context, [UIColor clearColor].CGColor);
CGContextSetLineWidth(context, 1.0);
CGContextSetShouldAntialias(context, true);
CGContextSetAllowsAntialiasing(context, true);
CGContextBeginPath (context);
CGContextMoveToPoint(context, xStart, yStart);
for (int i=0; i<points.count; i++) {
CGContextAddLineToPoint(context, xPoint, yPoint);
}
}
CGContextAddLineToPoint(context, xStart, yStart );
CGContextClip(context);
CGRect colorRect = CGRectMake(0, 0 , rectWidth, rectHeight);
CGContextSetFillColorWithColor(context, blockColor.CGColor);
CGContextFillRect(context, colorRect);
CGContextRestoreGState(context);
结果应该有平滑的线条,但它会出现锯齿状的可见像素,如下图所示:
知道问题出在哪里以及如何解决吗?
提前致谢
【问题讨论】:
-
你在画直方图,不是吗?
-
是的,它是一个直方图
标签: ios uiview core-graphics