CAAnimation在到达目的地之前结束

时间:2013-11-25 10:15:34

标签: ios calayer uibezierpath caanimation

我的CaLayer移动CAKeyframeAnimation。我希望在层到达终点之前结束层的移动,因为随机数量的层正在从不同位置向单个目标移动,当它们到达时,它看起来像雪花。

CGPoint startPoints = [self convertDegreesToPoints:latLonArr];
CGPoint endPoints = [self convertDegreesToPoints:[NSArray arrayWithObjects:@"41.0311",@"21.3403", nil]];

UIBezierPath *linePath = [UIBezierPath bezierPath];
[linePath moveToPoint:startPoints];
[linePath addLineToPoint:endPoints];

//gradient layer for the line


CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame = CGRectMake(0, 0, 150.0, 2.0);
gradient.cornerRadius = 5.0f;
gradient.startPoint = CGPointMake(0.0, 0.5);
gradient.endPoint = CGPointMake(1.0, 0.5);
gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor clearColor] CGColor],(id)[[colors objectAtIndex:i] CGColor],(id)[[colors objectAtIndex:i] CGColor],(id)[[UIColor clearColor] CGColor], nil];
[scrollViewContent.layer addSublayer:gradient];



CAKeyframeAnimation *anim = [CAKeyframeAnimation animationWithKeyPath:@"position"];
anim.path = [linePath CGPath];
anim.rotationMode = kCAAnimationRotateAuto;
anim.repeatCount = 0;
anim.duration = 1;
[gradient addAnimation:anim forKey:@"gradient"];

以下是它的外观:

enter image description here

此问题可转介至https://stackoverflow.com/questions/20125910/cagradientlayer-to-blend-in-with-the-end-location-of-the-cakeyframeanimation

我决定再问一次,因为也许我在上一篇文章中不够清楚,或者对于那些知道如何调查它的人来说,标题是奇怪的。

0 个答案:

没有答案