So, I have a function that randomly generates some CGPoints. Then I create CGPath from these points. I use this path in keyframe animation to animate the presentation around the screen.
The path is created using the following code:
- (CGMutablePathRef)generatePathFromCoordinates:(NSArray *)coordinates { CGMutablePathRef path = CGPathCreateMutable(); CGPoint point = [(NSValue *)[coordinates objectAtIndex:0] CGPointValue]; CGPathMoveToPoint(path, nil, point.x, point.y); for (int i=1; i < coordinates.count; i++) { point = [(NSValue *)[coordinates objectAtIndex:i] CGPointValue]; CGPathAddLineToPoint(path, nil, point.x, point.y); } return path; }
The code above works fine, but the animation looks a bit weird, so I would like to add a curve between the coordinates, rather than a straight line. Like in the picture below (amazing drawing skills that I know!). Path "A" is what I am doing now, and path "B" is what I was striving for:

After looking at the functions available in the CGPath link, I see several that could complete the job, CGPathAddArcToPoint CGPathAddCurveToPoint . I used these functions briefly, but I couldnβt get the desired effect (perhaps because I used them incorrectly)
Could you guys point me in the right direction to get a good curve?
Thank you in advance
source share