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"]; 
関連する問題