ドキュメントから:
アプリケーションがレイヤーの anchorPoint プロパティを変更した場合、動作は未定義です。Core Animation レイヤーを管理していないビューにこのメッセージを送信すると、例外が発生します。
https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSView_Class/Reference/NSView.html
あなたのビューは、変更されていないアンカー ポイントを持つ CALayer を管理していますか?
編集
同様のコードをセットアップすると、まったく同じ結果が得られました。原点またはアンカー ポイントを調整しないと、この問題を解決できません。私の理論では、この特定のメソッドにはバグが含まれているか (自動レイアウトの場合)、予期しない方法で動作するというものです。を使用して正しい効果を達成しましたCABasicAnimation
。
/* setup */
....
_view.layer.anchorPoint = CGPointMake(0.5f, 0.5f);
_view.layer.position = ...
[self startRefreshAnimation];
}
- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag
{
[self startRefreshAnimation];
}
-(void)startRefreshAnimation {
CABasicAnimation *anim2 = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
anim2.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
anim2.fromValue = [NSNumber numberWithFloat:previousRotation * (M_PI / 180.0f)];
anim2.toValue = [NSNumber numberWithFloat:(previousRotation + 90.0f) * (M_PI / 180.0f)];
previousRotation = previousRotation + 90.0f;
anim2.duration = 1.0f;
anim2.delegate = self;
[_view.layer addAnimation:anim forKey:@"transform"];
}