Created
August 6, 2012 13:46
-
-
Save codeswimmer/3274554 to your computer and use it in GitHub Desktop.
iOS: Push animation done programatically
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - (void)viewWillAppear:(BOOL)animated | |
| { | |
| [super viewWillAppear:NO]; | |
| CATransition *animation = [CATransition animation]; | |
| [animation setDelegate:self]; | |
| [animation setType:kCATransitionPush]; | |
| [animation setSubtype:kCATransitionFromRight]; | |
| [animation setDuration:0.40]; | |
| [animation setTimingFunction: | |
| [CAMediaTimingFunction functionWithName: | |
| kCAMediaTimingFunctionEaseInEaseOut]]; | |
| [self.view.layer addAnimation:animation forKey:kCATransition]; | |
| } | |
| - (IBAction) close | |
| { | |
| CATransition *animation = [CATransition animation]; | |
| [animation setDelegate:self]; | |
| [animation setType:kCATransitionPush]; | |
| // the fact that i only need this for close probably | |
| // indicates that i am doing something wrong | |
| switch (self.interfaceOrientation) | |
| { | |
| case UIInterfaceOrientationPortrait: | |
| [animation setSubtype:kCATransitionFromLeft]; | |
| break; | |
| case UIInterfaceOrientationPortraitUpsideDown: | |
| [animation setSubtype:kCATransitionFromRight]; | |
| break; | |
| case UIInterfaceOrientationLandscapeLeft: | |
| [animation setSubtype:kCATransitionFromTop]; | |
| break; | |
| case UIInterfaceOrientationLandscapeRight: | |
| [animation setSubtype:kCATransitionFromBottom]; | |
| break; | |
| } | |
| [animation setDuration:0.40]; | |
| [animation setTimingFunction: | |
| [CAMediaTimingFunction functionWithName: | |
| kCAMediaTimingFunctionEaseInEaseOut]]; | |
| [self.view.window.layer addAnimation:animation forKey:kCATransition]; | |
| [self dismissModalViewControllerAnimated:NO]; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment