-1
원 안에 호를 그리고 호를 채우려고합니다. 다음은 내가 사용하고있는 코드입니다 :목표 C - 원 안에 다중 호를 그립니다.
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextAddEllipseInRect(ctx, rect);
CGContextSetFillColor(ctx, CGColorGetComponents([[clrArray objectAtIndex:0] CGColor]));
CGContextFillPath(ctx);
CGFloat radius = 12.5;
CGFloat startAngle1 = DegreesToRadians(0);
CGFloat endAngle1 = DegreesToRadians(135);
CGFloat startAngle2 = DegreesToRadians(135);
CGFloat endAngle2 = DegreesToRadians(270);
//draw arc
CGPoint center = CGPointMake(radius,radius);
//Arc 1
CGContextAddArc(ctx,
center.x,
center.y,
radius,
startAngle1,
endAngle1,
YES);
[(UIColor*)[clrArray objectAtIndex:1] set];
CGContextFillPath(ctx);
//Arc 2
CGContextAddArc(ctx,
center.x,
center.y,
radius,
startAngle2,
endAngle2,
YES);
[(UIColor*)[clrArray objectAtIndex:2] set];
CGContextFillPath(ctx);
오른쪽 그림이 아닙니다. 만약 하나의 호만 제공한다면 각도가 180보다 작 으면 오른쪽 대담한 것도 아닙니다. 내가 뭘 잘못하고있어? 편집
: 여기 내가
를 사용하여 다른 솔루션을있어이 이미지의 시작 각도 0과 끝 각도 (45)를 사용
을 무슨 일이 일어나고 있는지의 이미지입니다 ** 어떤 의미에서 "그리기가 옳지 않은가"** –
그것은 그리기는하지만 틀리게 그린다. 내가 천사에게 0을 주었던 것은 x = 0 y = center.y이고 135는 원의 각도 일 것입니다. 하지만 대신 오른쪽 하단 모서리에 그려져 있습니다. – Hassy
그리고 끝점을 주면 서클 끝의 절반에 정확히 그려지며 시작점은 내가 언급 한 것과 같을 것입니다 – Hassy