CABasicAnimation cómo get el ángulo de rotation actual

Tengo un problema con CABasicAnimation. Es similar a esa publicación: CABasicAnimation rotate vuelve a la position original

Entonces, tengo uiimageview que rotan en touchMove. En el método touchEnd invoke que hace "animation de inercia":

-(void)animationRotation: (float)beginValue { CABasicAnimation *anim; anim = [CABasicAnimation animationWithKeyPath:@"transform.rotation"]; anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]; anim.duration = 0.5; anim.repeatCount = 1; anim.fillMode = kCAFillModeForwards; anim.fromValue = [NSNumber numberWithFloat:beginValue]; [anim setDelegate:self]; anim.toValue = [NSNumber numberWithFloat:(360*M_PI/180 + beginValue)]; [appleView.layer addAnimation:anim forKey:@"transform"]; CGAffineTransform rot = CGAffineTransformMakeRotation(360*M_PI/180 + beginValue); appleView.transform = rot; } 

Esta animation funciona bien, pero si invoco touchBegan antes de que animationRotation finalice, el ángulo de rotation es beginValue. Necesito ángulo de rotation actual del catéter. Como un experimento, declaro el método

  -(vod) animationDidStop:(CAAnimation *)anim finished:(BOOL)flag { NSLog(@"Animation finished!"); } 

y parece que funciona. pero no sé cómo get ese valor de ángulo o CGAffineTransform para mi UIImageView en animationDidStop. ¿Incluso es posible hacerlo? Gracias.

debe usar el método presentationLayer para get properties de capa durante la animation en vuelo.

por lo que su código debería ser así,

  #define RADIANS_TO_DEGREES(__ANGLE__) ((__ANGLE__) / (float)M_PI * 180.0f) -(void)animationRotation: (float)beginValue { CABasicAnimation *anim; anim = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]; anim.duration = 0.5; anim.repeatCount = 1; anim.fillMode = kCAFillModeForwards; anim.fromValue = [NSNumber numberWithFloat:beginValue]; [anim setDelegate:self]; //get current layer angle during animation in flight CALayer *currentLayer = (CALayer *)[appleView.layer presentationLayer]; float currentAngle = [(NSNumber *)[currentLayer valueForKeyPath:@"transform.rotation.z"] floatValue]; currentAngle = roundf(RADIANS_TO_DEGREES(currentAngle)); NSLog(@"current angle: %f",currentAngle); anim.toValue = [NSNumber numberWithFloat:(360*M_PI/180 + beginValue)]; [appleView.layer addAnimation:anim forKey:@"transform"]; CGAffineTransform rot = CGAffineTransformMakeRotation(360*M_PI/180 + beginValue); appleView.transform = rot; }