2016-09-23 70 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