I'm attempting to animate drawing this particular image:
however, I realized that trying to draw this with a CGPath is not really possible. I figured the next solution would be to try and reveal this image based on a close approximation on it's path. So I managed to draw out a CGPath that's close to this image:
I was hoping someone could help me figure it out!
I do have the following code to at least stroke the path. I'm using SVGKit to help with path creation from an SVG File:
-(void)animateItAll{
self.thePath = [UIBezierPath bezierPathWithCGPath:[PocketSVG pathFromSVGFileNamed:@"SquiggleLine"]];
self.thePath.lineCapStyle = kCGLineCapRound;
self.thePath.lineJoinStyle = kCGLineJoinRound;
CAShapeLayer *shapeView = [[CAShapeLayer alloc] init];
[shapeView setPath:self.thePath.CGPath];
shapeView.fillColor = [[UIColor clearColor] CGColor];
shapeView.strokeColor = [[UIColor redColor] CGColor];
shapeView.lineWidth = 8.0f;
[[self.view layer] addSublayer: shapeView];
CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
pathAnimation.duration = 1.0;
pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
pathAnimation.fromValue = [NSNumber numberWithFloat:0.0f];
pathAnimation.toValue = [NSNumber numberWithFloat:1.0f];
//pathAnimation.toValue = (id) self.thePath.CGPath;
[shapeView addAnimation:pathAnimation forKey:nil];
}