2016-09-28 2 views
0

나는 그 안에 "구멍"과 투명한 주변 (see screenshot)을 포함하는 CAShapeLayer를 가지고 있습니다. 그 원의 반지름을 변화 시키도록 애니메이션하고 싶습니다. (더 크거나 작게 만들고 싶습니다). 어떤 아이디어?CAShapleLayer의 경로를 애니메이트하는 방법은 무엇입니까?

CAShapeLayer *fillLayer = [self getCircleLayerWithRadius:self.view.frame.size.width/2]; 

getCirleWithRadius 기능 :

-(CAShapeLayer *)getCircleLayerWithRadius:(NSInteger)radius { 
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:self.view.frame cornerRadius:0]; 
UIBezierPath *circlePath = [self getCirclePathWithRadius:radius]; 
[path appendPath:circlePath]; 
path.usesEvenOddFillRule = YES; 
CAShapeLayer *fillLayer = [CAShapeLayer layer]; 
fillLayer.path = path.CGPath; 
fillLayer.fillRule = kCAFillRuleEvenOdd; 
fillLayer.fillColor = [UIColor grayColor].CGColor; 
fillLayer.opacity = 0.5; 
return fillLayer; } 

getCircleWithRadius :

- (UIBezierPath *)getCirclePathWithRadius:(NSInteger)radius { 
CGRect rect = self.view.frame; 
UIBezierPath *circlePath; 
circlePath = [UIBezierPath bezierPathWithArcCenter:(CGPoint){rect.size.width/2, rect.size.height/2} radius:radius startAngle:0 endAngle:M_PI*2 clockwise:YES]; 
return circlePath;} 
+0

'CABasicAnimation' – ColdSteel

답변

0

@"path" 키 'CABasicAnimation'를 사용해보십시오

이 내 계층입니다. 다음은 애니메이션 구성 예제입니다.

CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"path"]; 
    animation.duration = [CATransaction animationDuration]; 
    animation.timingFunction = [CATransaction animationTimingFunction]; 
    animation.fromValue = (id)oldPath; 
    animation.toValue = (id)path; 
    [fillLayer addAnimation:animation forKey:@"pathAnimation"]; 
관련 문제