Is it possible to draw an elliptical arc like SVG path, in CoreGraphics and how?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I ran into the same thing tonight. CG doesn’t offer an easy way to draw a non-circular arc, but you can do it using CGPath and a suitable transformation matrix. Suppose you want an arc of an axis-aligned ellipse starting at left,top and with a size of width,height. Then you can do something like this:
Note that if you want to draw a pie-shaped wedge, then just surround the “CGContextAddPath” call with a CGContextMoveToPoint(cx,cy) and a CGContextAddLineToPoint(cx,cy), and use CGContextFillPath instead of CGContextStrokePath. (Or if you want to fill and stroke at the same time, use CGContextDrawPath.)