Skip to content

Instantly share code, notes, and snippets.

@codeswimmer
Created August 6, 2012 13:46
Show Gist options
  • Select an option

  • Save codeswimmer/3274554 to your computer and use it in GitHub Desktop.

Select an option

Save codeswimmer/3274554 to your computer and use it in GitHub Desktop.
iOS: Push animation done programatically
- (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