Skip to content

Instantly share code, notes, and snippets.

@jaiversin
Created April 30, 2013 19:32
Show Gist options
  • Save jaiversin/5491280 to your computer and use it in GitHub Desktop.
Save jaiversin/5491280 to your computer and use it in GitHub Desktop.
Fade transition for iOS
//Navigate to the controller
- (IBAction)myButtonPressed:(id)sender {
MyVC *myVC = [[MyVC alloc] initWithNibName:@"MyVC" bundle:nil];
CATransition* transition = [CATransition animation];
transition.duration = 0.5;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionFade;
[self.navigationController.view.layer addAnimation:transition forKey:nil];
[self.navigationController pushViewController:myVC animated:NO];
}
//Dismiss the controller
- (IBAction)backButtonPressed:(id)sender
{
CATransition* transition = [CATransition animation];
transition.duration = 0.5;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionFade;
[self.navigationController.view.layer addAnimation:transition forKey:nil];
[self.navigationController popViewControllerAnimated:NO];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment