/ Published in: Objective C
A snippet of code from IVM-Awesomesauce that shows how to use included classes to perform a custom animation between two UIViewControllers.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
- (IBAction)leButtonTapped:(id)sender { NextViewController *nvc = [[NextViewController alloc] initWithNibName:@"NextViewController" bundle:nil] ; // This performs a flipboard-like animation ASAnimatedTransition *animatedTransition = [[ASAnimatedTransition alloc] init] ; animatedTransition.sourceView = self.view ; animatedTransition.destinationView = nvc.view ; animatedTransition.hostView = self.view ; animatedTransition.initializeAnimationBlock = ^(AnimationView *animationView, CALayer *sourceLayer, CALayer *destinationLayer) { CATransform3D transform = CATransform3DIdentity ; transform.m34 = 1.0 / -200 ; transform = CATransform3DTranslate(transform, 0, 5, -25) ; destinationLayer.transform = transform ; } ; animatedTransition.performAnimationBlock = ^(AnimationView *animationView, CALayer *sourceLayer, CALayer *destinationLayer) { [CATransaction setAnimationDuration:0.6] ; sourceLayer.position = CGPointMake(sourceLayer.position.x, -sourceLayer.frame.size.height/2.0) ; destinationLayer.transform = CATransform3DIdentity ; } ; animatedTransition.animationFinishedBlock = ^() { [self.navigationController pushViewController:nvc animated:NO] ; } ; [animatedTransition performTransition] ; }
URL: https://github.com/leftspin/IVM-Awesomesauce/blob/master/IVMAwesomesauce/RootViewController.m