Example from IVM-Awesomesauce


/ Published in: Objective C
Save to your folder(s)

A snippet of code from IVM-Awesomesauce that shows how to use included classes to perform a custom animation between two UIViewControllers.


Copy this code and paste it in your HTML
  1. - (IBAction)leButtonTapped:(id)sender
  2. {
  3. NextViewController *nvc = [[NextViewController alloc] initWithNibName:@"NextViewController" bundle:nil] ;
  4.  
  5. // This performs a flipboard-like animation
  6. ASAnimatedTransition *animatedTransition = [[ASAnimatedTransition alloc] init] ;
  7. animatedTransition.sourceView = self.view ;
  8. animatedTransition.destinationView = nvc.view ;
  9. animatedTransition.hostView = self.view ;
  10. animatedTransition.initializeAnimationBlock = ^(AnimationView *animationView, CALayer *sourceLayer, CALayer *destinationLayer)
  11. {
  12. CATransform3D transform = CATransform3DIdentity ;
  13. transform.m34 = 1.0 / -200 ;
  14. transform = CATransform3DTranslate(transform, 0, 5, -25) ;
  15. destinationLayer.transform = transform ;
  16. } ;
  17. animatedTransition.performAnimationBlock = ^(AnimationView *animationView, CALayer *sourceLayer, CALayer *destinationLayer)
  18. {
  19. [CATransaction setAnimationDuration:0.6] ;
  20. sourceLayer.position = CGPointMake(sourceLayer.position.x, -sourceLayer.frame.size.height/2.0) ;
  21. destinationLayer.transform = CATransform3DIdentity ;
  22. } ;
  23. animatedTransition.animationFinishedBlock = ^()
  24. {
  25. [self.navigationController pushViewController:nvc animated:NO] ;
  26. } ;
  27. [animatedTransition performTransition] ;
  28. }

URL: https://github.com/leftspin/IVM-Awesomesauce/blob/master/IVMAwesomesauce/RootViewController.m

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.