CABasicAnimationに問題があります。そのポストに似ています:CABasicAnimation rotate returns to original positionCABasicAnimation現在の回転角度の取得方法
私はtouchMoveで回転するuiimageviewを持っています。このアニメーションは正常に動作しますが、animationRotationが終了する前に、私はtouchBeganを起動する場合は、回転角度があるBeginValueある
-(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;
}
:。touchEndでは、「慣性のアニメーション」を行うメソッドを呼び出します私は現在の回転角のカフを必要とします。実験として、私は方法を宣言します。
-(vod) animationDidStop:(CAAnimation *)anim finished:(BOOL)flag
{
NSLog(@"Animation finished!");
}
と思われます。私はどのように角度の値を取得するかわからないまたはCGAffineTransform私のUIImageViewのanimationDidStop。 することもできますか?ありがとう。
おかげで、私はこれを試してみました、それは動作しますが、ない非常にそれが必要として。私はNSTimerのアニメーションを使用しましたが、とにかく感謝しています:-) – frankWhite
レイヤーの現在表示されている回転を取得する方法のためにUpvoted。 – geraldWilliam