My CALayer transform holds after animation, but the perspective disappears My CALayer transform holds after animation, but the perspective disappears xcode xcode

My CALayer transform holds after animation, but the perspective disappears


Animation only affects the appearance of the view during the animation. It doesn't get applied to the view after the animation ends. You need to do this yourself. I'm guessing something like this right after adding the animation will work:

self.layer.transform = transform;

You can do this right away, as the animation will hide it until the animation completes.


Try this :

- (void) swipe:(UISwipeGestureRecognizer *)recognizer{            CATransform3D transform = CATransform3DIdentity;    transform.m34 = -10 / 850.0;    transform = CATransform3DRotate(transform, D2R(-45), 0, 1.0, 0);    CABasicAnimation *transformAnimation = [CABasicAnimation animationWithKeyPath: @"transform"];    transformAnimation.fillMode = kCAFillModeForwards;    transformAnimation.removedOnCompletion = NO;    transformAnimation.toValue = [NSValue valueWithCATransform3D:transform];    transformAnimation.duration = 0.5;    [self.layer addAnimation:transformAnimation forKey:@"transform"];}

And end the effect is like this :

enter image description here