커스텀 SGCircleView에서 원을 그릴 때 CoreGraphics를 사용합니다. 접촉 할 때 방사형 그래디언트로 원을 채우기를 원할 때, 내 appraoch는 원시 원 (SGCircleLayer)으로 한 레이어를 그린 다음 그라디언트가있는 다른 레이어를 추가하는 것입니다. 문제는 원이 어떻게 든 "나뭇결"로 보인다는 것입니다. SGCircleLayer의 코드입니다CGLayer의 그리기 품질을 향상시키는 방법
:
- (void) drawLayer: (CALayer *) layer inContext: (CGContextRef) ctx {
UIGraphicsPushContext(ctx);
UIBezierPath *circlePath = [UIBezierPath bezierPathWithOvalInRect: CGRectInset(layer.bounds, CLineWidth/2, CLineWidth/2)];
self.path = circlePath.CGPath;
[[UIColor whiteColor] setStroke];
circlePath.lineWidth = CLineWidth;
[circlePath stroke];
UIGraphicsPopContext();
}
테스트 목적으로 나는 정확히 같은 반경과 라인이 정말 그려 smoth 보이는 사용자 정의 SGCircleTestView의의 drawRect에 그려진 폭이 다른 원을 추가했습니다.
- (void) drawRect: (CGRect) rect {
CGRect bounds = CGRectInset(rect, CLineWidth * 0.5, CLineWidth * 0.5);
UIBezierPath* circlePath = [UIBezierPath bezierPathWithOvalInRect: bounds];
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, CLineWidth2);
CGContextSetStrokeColorWithColor(context, [UIColor whiteColor].CGColor);
[circlePath stroke];
}
무슨 일이 내 SGCircleLayer의 코드를 그리기 잘못하고있는 중이 야 :
이 SGCircleTestView 내의 drawRect의 코드 (부드러운 원)이다?