いくつかのアニメーションをいじっていますが、たまたま近くにテストするデバイスがありません。空を横切る雲の簡単なアニメーションがあります。雲は次の方法でアニメーション化されます。
-(void)animateLayer:(CALayer*)layer toPosition:(CGPoint)position withDuration:(CGFloat)duration{
// Prepare the animation from the current position to the new position
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"];
animation.fromValue = [layer valueForKey:@"position"];
animation.toValue = [NSValue valueWithCGPoint:position];
animation.delegate = self;
animation.duration = duration;
[animation setValue:layer forKey:@"cloudLayer"];
// Update the layer's position so that the layer doesn't snap back when the animation completes.
layer.position = position;
// Add the animation, overriding the implicit animation.
[layer addAnimation:animation forKey:@"position"];
}
レイヤーには単純な部分的に透明な画像が含まれています。ただし、これを実行すると、CPU 使用率が MacBook Air で予想されるよりもはるかに高くなります。私が非効率的にしていることはありますか?それとも、シミュレーターはアニメーションなどの特定のタスクで大量のリソースを消費するだけですか?