问候!我试图在驻留在可缩放UISCrollView中的CALayer中绘制一系列圆圈。这是可以缩放的图层。如果我画使用CAShapeLayer圆圈,然后他们放大精美:CALayer的抗锯齿图纸
CAShapeLayer plotLayer = [CAShapeLayer layer];
plotLayer.bounds = self.bounds;
plotLayer.anchorPoint = CGPointZero;
plotLayer.position = CGPointZero;
CGMutablePathRef path = CGPathCreateMutable();
for (id one in many) {
CGRect ellipseRect = [one circleRect];
CGPathAddEllipseInRect(path, NULL, ellipseRect);
}
plotLayer.path = path
CFRelease(path);
[self.layer addSublayer:plotLayer];
[plotLayer setNeedsDisplay];
然而,当我尝试用香草核心图形画在我的drawLayer:inContext的:法,圆得非常锯齿(彻头彻尾的亲走样!)抗锯齿暗中捣鬼再多似乎帮助:
-(void)drawLayer:(CALayer *)layer inContext:(CGContextRef)context
{
CGContextSetAllowsAntialiasing(context, true);
CGContextSetShouldAntialias(context, true);
CGContextClip(context);
for (id one in many) {
CGRect ellipseRect = [one circleRect];
CGContextStrokeEllipseInRect(context, ellipseRect);
}
}
我试图找出CAShapeLayer做能得到这样好的抗锯齿使(除了我自己的熏陶),我可以充分利用我的绘图中的核心图形,而不仅仅是我可以用CAShapeLayer获得的笔画/填充。我是否错过了某处的转换?
非常感谢!
感谢您的想法,但没有运气。 CGContextSetInterpolationQuality不起作用。我也试过CGContextSetFlatness,它也没有效果。 – kalperin 2011-05-27 16:20:03