文档中说CAShapLayer是抗锯齿的,为什么会出现这种结果。 我还在drawRect方法中使用CGContext画了一个圆,效果非常完美。
UIBezierPath *path = [UIBezierPath bezierPath];
[path appendPath:[UIBezierPath bezierPathWithOvalInRect:CGRectMake(150, 300, 136, 136)]];
self.circleLayer = [CAShapeLayer layer];
self.circleLayer.path = path.CGPath;
self.circleLayer.frame = self.bounds;
self.circleLayer.fillColor = [[UIColor whiteColor] colorWithAlphaComponent:0.6].CGColor;
[self.layer addSublayer:self.circleLayer];
UIBezierPath
方法addArcWithCenter
时,半径为非整数(例如150.2而不是150),则CAShapeLayer
的抗锯齿伪影会更少分散注意力。 - Rob