I want to create an animation which "create a copy of a view, move this copy from a point to another point while decreasing opacity until it totally disappear".
I suppose i need to do it through a CABasicAnimation
so i tried something like that :
CGPoint point = CGPointMake(200, 0);
// copy layer
CALayer *layer = [[CALayer alloc] initWithLayer:self.animatedView.layer];
[self.animatedView.layer addSublayer:layer];
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"];
animation.fromValue = [layer valueForKey:@"position"];
animation.toValue = [NSValue valueWithCGPoint:point];
animation.duration = 2.0f;
CABasicAnimation *oanimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
oanimation.fromValue = @1;
oanimation.toValue = @0;
oanimation.duration = 1.0f;
// move copy layer
[layer addAnimation:animation forKey:@"position"];
[layer addAnimation:oanimation forKey:@"opacity"];
But nothings append and i think it's a normal situation regarding to documentation :
This initializer is used to create shadow copies of layers, for example, for the presentationLayer method. Using this method in any other situation will produce undefined behavior. For example, do not use this method to initialize a new layer with an existing layer’s content.
Someone already did this kind of animation before ?
Thx for your help.