저는 애니메이션을 가지고 놀았습니다. 테스트 할 장치가 가까이에 없습니다. 하늘을 가로 질러 움직이는 구름의 간단한 애니메이션이 있습니다. 구름은이 방법으로 애니메이션됩니다.iOS 시뮬레이터가 애니메이션을 덜 효율적으로 실행합니까?
-(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에서 기대하는 것보다 훨씬 높습니다. 내가 비효율적으로하는 일이 있습니까? 아니면 시뮬레이터가 애니메이션과 같은 특정 작업에 많은 리소스를 씹었습니까?
아, 왜 CPU 사용률이 그렇게 높은지 알 수있었습니다. 큰 레이어를 만들었으므로 불투명도를 YES로 설정하지 않았기 때문입니다. 어쨌든 ios 시뮬레이터가 장치와 비교하여 특정 작업을 처리하는 방법에 차이가 있는지 알고 싶습니다. – Saltymule