0
所以我的动画圆的路径,例如(完美的作品):当前值CABasicAnimation
CGPoint center = CGPointMake([self bounds].size.width/2.0, [self bounds].size.height/2.0);
circle.path = [UIBezierPath bezierPathWithArcCenter:center
radius:radius-13 startAngle:DEGREES_TO_RADIANS(0) endAngle:DEGREES_TO_RADIANS([self percentageToAngle:100]) clockwise:NO].CGPath;
circle.fillColor = [UIColor clearColor].CGColor;
circle.strokeColor = [UIColor blackColor].CGColor;
circle.lineWidth = 27.0;
[self.layer addSublayer:circle];
float currentAngle = [(NSNumber *)[ sublayer valueForKeyPath:@"strokeEnd" ] floatValue];
CABasicAnimation *drawAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
drawAnimation.duration = 2.0;
drawAnimation.repeatCount = 0.0;
drawAnimation.removedOnCompletion = NO;
drawAnimation.fromValue = [NSNumber numberWithFloat:0.0];
drawAnimation.toValue = [NSNumber numberWithFloat:1.0];
drawAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
drawAnimation.delegate = self;
[drawAnimation setValue:kAnimationName forKey:kLayerName];
[circle addAnimation:drawAnimation forKey:kAnimationName];
如果我停止动画中游,怎么我得到的电流值,这是在哪里?无论是角度还是fromValue和toValue之间的值?
感谢您的回复。但是,不,那不行。我不围绕任何轴旋转任何东西。动画正在沿着圆圈的路径发展。我用valueForKeyPath尝试了一个类似的东西:@“strokeEnd”,但它总是1,不管当我停止动画。 – user3564870 2014-09-03 02:45:38
我很抱歉它错过了。我在几个小时的研究,但是,我无法弄清楚。 – oddeyes 2014-09-04 08:05:10