2016-09-23 59 views
3

画骷髅我想在Objective C中绘制动画将在目标C

我捕捉使用AVCaptureSession用户的照片,并显示在的UIImageView的映像运行动画。 一旦显示图像,我必须从头顶部开始到下巴结束进行RUN动画。脸上总共有13个点。 2在前额, 2在鼻梁, 2的目光结束, 2在每个鼻开幕, 2开始和嘴唇的结束, 2,在两颊, 1在下巴结尾

我想运行动画,它将从头部开始并在下巴处结束,并从上述每个点画出线条。 这里是像样的方式的示例图像。

目标c是否可能 如果是,请指导相同。

enter image description here

在此先感谢。

回答

1

创建点贝塞尔路径要动画像这样:

CAShapeLayer *bezier = [[CAShapeLayer alloc] init]; 

bezier.path   = bezierPath.CGPath; 
bezier.strokeColor = [UIColor blueColor].CGColor; 
bezier.fillColor  = [UIColor clearColor].CGColor; 
bezier.lineWidth  = 5.0; 
bezier.strokeStart = 0.0; 
bezier.strokeEnd  = 1.0; 
[self.view.layer addSublayer:bezier]; 

然后进行动画这样的路径:

UIBezierPath *path = [UIBezierPath bezierPath]; 

[path moveToPoint:CGPointMake(0.0, 0.0)]; 

[path addLineToPoint:CGPointMake(200.0, 200.0)]; 
[path addLineToPoint:CGPointMake(200.0, 200.0)]; 
..... add all your points ..... 

通过这样的路径创建形状图层

CABasicAnimation *animateStrokeEnd = [CABasicAnimation animationWithKeyPath:@"strokeEnd"]; 
animateStrokeEnd.duration = 10.0; 
animateStrokeEnd.fromValue = [NSNumber numberWithFloat:0.0f]; 
animateStrokeEnd.toValue = [NSNumber numberWithFloat:1.0f]; 
[bezier addAnimation:animateStrokeEnd forKey:@"strokeEndAnimation"]; 

这个答案主要取自这里:

Drawing animation