I am just trying to translate the layer back to its original position, after already have translated it once. I can always store the layer position I translated to in a property, but it seems like there is a better way. I am doing something like this to translate my layer:
CABasicAnimation *slide = [CABasicAnimation animationWithKeyPath:@"transform.translation.x"];
slide.byValue = [NSNumber numberWithFloat:translationValue];
slide.duration = duration;
slide.removedOnCompletion = NO;
slide.fillMode = kCAFillModeForwards;
slide.autoreverses = NO;
[layer addAnimation:slide forKey:KEYPATH_POSITION];
I was trying to do something like the following, but this has no animation, it just appears back to its original position.
CABasicAnimation *slide = [CABasicAnimation animationWithKeyPath:@"position"];
slide.toValue = [layer valueForKey:@"position"];
slide.duration = duration;
slide.removedOnCompletion = NO;
slide.fillMode = kCAFillModeForwards;
slide.autoreverses = NO;
[layer addAnimation:slide forKey:KEYPATH_POSITION];