I had a problem while drawing an arc inside my drawing function inside a subclass of CALayer. The implementation for this drawing function is as follows:
-(void)drawInContext:(CGContextRef)ctx { CGPoint center = CGPointMake(self.bounds.size.width/2, self.bounds.size.height/2); CGFloat radius = MIN(center.x, center.y); CGContextBeginPath(ctx); CGContextAddArc(ctx, center.x, center.y, radius, DEG2RAD(0), DEG2RAD(90), YES); CGContextSetStrokeColorWithColor(ctx, [UIColor whiteColor].CGColor); CGContextSetLineWidth(ctx, 5); CGContextDrawPath(ctx, kCGPathStroke); }
There is nothing revolutionary here, but it is strange that he draws an arc counterclockwise, although I indicated that it will be clockwise. Conversely, when I specify NO for a parameter in a clockwise direction, it draws an arc in a clockwise direction. I did some research on inverted coordinate systems and realized that this could be a problem, but I didn't want to just specify the opposite bool parameter, which I had in mind. Any suggestions on how to fix this?
Thanks!
source share