- (void)updateValueFromAnimationsForLayers:(NSArray*)layers{
[CATransaction begin];
[CATransaction setDisableActions:YES];

for (CALayer *layer in layers) {
for (NSString *animKey in layer.animationKeys) {
CAAnimation *anim = [layer animationForKey:animKey];
[self updateValueForAnimation:anim theLayer:layer];
}
}

[CATransaction commit];
}

- (void)updateValueForAnimation:(CAAnimation*)anim theLayer:(CALayer *)layer{
if ([anim isKindOfClass:[CABasicAnimation class]]) {
CABasicAnimation *basicAnim = (CABasicAnimation*)anim;
if (!basicAnim.autoreverses) {
[layer setValue:basicAnim.toValue forKeyPath:basicAnim.keyPath];
}
}
else if ([anim isKindOfClass:[CAKeyframeAnimation class]]) {
CAKeyframeAnimation *keyAnim = (CAKeyframeAnimation*)anim;
if (!anim.autoreverses) {
[layer setValue:keyAnim.values.lastObject forKeyPath:keyAnim.keyPath];
}
}
else if ([anim isKindOfClass:[CAAnimationGroup class]]) {
CAAnimationGroup *groupAnim = (CAAnimationGroup*)anim;
for (CAAnimation *subAnim in groupAnim.animations) {
[self updateValueForAnimation:subAnim theLayer:layer];
}
}
}
