0

Below is the code which draws the Arc from M_PI/2 to M_PI.

CGContextRef contet=UIGraphicsGetCurrentContext();

CGMutablePathRef path = CGPathCreateMutable();
CGPathAddArc(path, NULL, CGRectGetMidX(rect), CGRectGetMidY(rect), CGRectGetMidX(rect),  M_PI/2.0,M_PI, YES);

CGContextAddPath(contet, path);
CGContextSetStrokeColorWithColor(contet, [UIColor redColor].CGColor);
CGContextStrokePath(content);

Below is the drawing of the above code.

enter image description here

I was expecting it to draw it in the empty or missing part , as its clockwise. I referred to this answer Why does giving addArcWithCenter a startAngle of 0 degrees make it start at 90 degrees? but, I don't know where I am wrong.

Community
  • 1
  • 1
NNikN
  • 3,720
  • 6
  • 44
  • 86

2 Answers2

1

Because,in Core Graphics,the origin is at left/bottom

Flipping horizontally changes clockwise to anti clockwise and vice versa

You just need to change clockwise to NO to get what you want

Leo
  • 24,596
  • 11
  • 71
  • 92
0

You should just pay more attention to the method you used.

CGPathAddArc(path, NULL, CGRectGetMidX(rect), CGRectGetMidY(rect), CGRectGetMidX(rect),  M_PI/2.0,M_PI, NO);

Just change the last parameter to NO, you will get what you want, it can control the drawing direction.

Alanc Liu
  • 1,294
  • 10
  • 15