I have a problem with CABasicAnimation. This is similar to this post: CABasicAnimation rotate returns to its original position
So, I have uiimageview that rotate in touchMove. The inertia animation method is called in the touchEnd method:
-(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; }
This animation works fine, but if I call touchBegan before the animation, then the rotation of the rotation angle starts from the beginning. I need a rotation angle. As an experiment, I declare a method
-(vod) animationDidStop:(CAAnimation *)anim finished:(BOOL)flag { NSLog(@"Animation finished!"); }
and it seems to work. but I donβt know how to get this angle value or CGAffineTransform for my UIImageView in animationDidStop. Can it even be done? Thanks.
frankwhite
source share