4

プログレスバーの基本的な線画アニメーションを実装しました.線には丸いキャップエッジがあります.線の描画をアニメーション化すると、線の始まりは丸いキャップになりますが、最後は正方形になります. 以下は私が使用しているコードですが、何か不足していますか??

CAShape レイヤー コード :

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

[lineLayer setFrame: CGRectMake(0,
                                0,
                                wifisyncView.popUpView.frame.size.width,
                                wifisyncView.popUpView.frame.size.height)];

[lineLayer setPath: [linePath CGPath]];
lineLayer.lineWidth = 9.0f;
lineLayer.strokeEnd = 9.0f;
lineLayer.fillColor = [[UIColor orangeColor] CGColor];
lineLayer.lineCap = kCALineCapRound;
[lineLayer setStrokeColor:[[UIColor orangeColor] CGColor]];
[lineLayer setMasksToBounds:YES];
lineLayer.cornerRadius = 30.0f;

CABASIC アニメーション コード :

CABasicAnimation *drawAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
drawAnimation.duration            = 5.0; // "animate over 5 seconds "
drawAnimation.repeatCount         = 1.0;  // Animate only once..
drawAnimation.removedOnCompletion = NO;// Remain stroked after the animation..
drawAnimation.fillMode = kCAFillModeForwards;

// Animate from no part of the stroke being drawn to the entire stroke being drawn
drawAnimation.fromValue = [NSNumber numberWithFloat:0.0f];
drawAnimation.toValue   = [NSNumber numberWithFloat:1.0f];

// Experiment with timing to get the appearence to look the way you want
drawAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
drawAnimation.delegate = self;
// Add the animation to the circle
[lineLayer addAnimation:drawAnimation forKey:@"drawLineAnimation"];

添付画像:ここに画像の説明を入力

4

1 に答える 1