- (void)updateValueFromPresentationLayerForAnimation:(CAAnimation*)anim theLayer:(CALayer *)layer{
if ([anim isKindOfClass:[CABasicAnimation class]] || [anim isKindOfClass:[CAKeyframeAnimation class]]) {
CABasicAnimation *basicAnim = (CABasicAnimation*)anim;
[layer setValue:[layer.presentationLayer valueForKeyPath:basicAnim.keyPath] forKeyPath:basicAnim.keyPath];
}
else if ([anim isKindOfClass:[CAAnimationGroup class]]) {
CAAnimationGroup *groupAnim = (CAAnimationGroup*)anim;
for (CAAnimation *subAnim in groupAnim.animations) {
[self updateValueFromPresentationLayerForAnimation:subAnim theLayer:layer];
}
}
}
