我有一个组件,它有一个UIView子类和一个自定义的CAlayer。CALayer和UIView的差异图
在UIView的存在是绘制CoreGraphics中的圆圈,这是代码:
CGRect b = self.bounds;
int strokeSize = 2;
CGRect arcBounds = CGRectMake(b.origin.x+1, b.origin.y+1, b.size.width-2, b.size.height-2);
CGContextSaveGState(ctx); {
CGContextSetLineWidth(ctx, strokeSize);
CGContextSetStrokeColorWithColor(ctx, [UIColor lightGrayColor].CGColor);
CGContextStrokeEllipseInRect(ctx, arcBounds);
} CGContextRestoreGState(ctx);
当我绘制了UIView内drawRect方法是圆它完美的作品和绘制圆光滑,看起来不错。
问题出现在我画另一个圆时,但第二个画在CALayer中,实际上是在我的自定义CALayer的drawInContext方法中。使用相同的代码,圆圈看起来不太好,并且在边界上有一些“像素化”。
任何可能发生的线索的线索?提前致谢。