I have two views, and I want to switch between the two views using basic animation, animating the layer of each of the views. The animation I want is similar to the one provided by UIViewAnimationOptionTransitionFlipFromLeft , but I could not do it. I could make the layer rotate 180, and then when the animation stops, I move on to the next view. How can I do that?
I used the code as shown below:
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform"]; self.view.layer.zPosition = 100; CATransform3D transform = CATransform3DMakeRotation(M_PI, 0, 1, 0); [animation setToValue:[NSValue valueWithCATransform3D:transform]]; [animation setDuration:.5]; [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]]; [animation setFillMode:kCAFillModeForwards]; [animation setRemovedOnCompletion:YES]; [animation setDelegate:self]; [self.view.layer addAnimation:animation forKey:@"test"];
and in the delegate I move on to the next view. But that doesnโt make much sense, and the animation is not as lively as the default animation provides. how can this be achieved?
source share