計算が必要な回転および移動プロパティのUIView
設定を含むの複雑な連続アニメーションが必要なため、標準のアニメーションはオプションではありません。CATransform3D
CALayer
アニメーションを使用するようになりました。そしてこれを持ってください:
self.displayLink = [self.window.screen displayLinkWithTarget:self selector:@selector(update:)];
[self.displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
- (void)update:(CADisplayLink*)sender
{
CGFloat elapsedTime = sender.timestamp - self.lastTimestamp;
self.lastTimestamp = sender.timestamp;
self.rotation += elapsedTime * 0.1; // Factor determines speed.
// This is just example for SO post; the real animation is more complicated!
CATransform3D transform;
transform = CATransform3DMakeRotation(self.rotation, 1.0, 0.0, 0.0);
self.imageLayer.transform = transform;
}
これself.imageLayer
は、画像CALayer
がcontents
設定され、ベースビューにサブレイヤーとして追加された です。
それは「少し」回転しますが、連続的にではなく、時々停止したり、少し逆回転したりするようです。
値がはるかにインクリメントされるため、新しい値を割り当てtransform
ても効果がないことがよくあるようです。self.rotation
を追加し[self setNeedsDisplay]
ても役に立ちませんでした。
私はCALayer
まだ s をあまり使っていないので、非常に基本的なものが欠けていると思います。しばらくそれを見つけようとしましたが、私が見つけたすべての例は、私が望むものとはかけ離れているようです.