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