7
我的CABasicAnimation存在一些问题。它类似于该帖子:CABasicAnimation rotate returns to original positionCABasicAnimation如何获取当前的旋转角度
所以,我有uiimageview在touchMove中旋转。在touchEnd调用方法做“的动画惯性”:
-(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;
}
这部动画工作正常,但如果我调用touchBegan animationRotation结束前,旋转角度为beginValue。我需要阴极电流旋转角度。作为一个实验,我宣布方法
-(vod) animationDidStop:(CAAnimation *)anim finished:(BOOL)flag
{
NSLog(@"Animation finished!");
}
和它似乎工作。但我不知道如何在animationDidStop中为我的UIImageView获取角度值或CGAffineTransform值。 这甚至有可能吗?谢谢。
谢谢,我想这一点,它的工作原理,但并不完全,因为它应该。我用NSTimer动画..但无论如何感谢:-) – frankWhite 2012-04-30 17:52:01
Upvoted获取图层的当前可见旋转的方法。 – geraldWilliam 2016-09-29 22:28:09