PushViewController with Custom Animation
@implementation UINavigationController (Additions)
- (void) pushController: (UIViewController*) controller
withTransition: (UIViewAnimationTransition) transition
{
/*[UIView beginAnimations:nil context:NULL];
[self pushViewController:controller animated:NO];
[UIView setAnimationDuration:.5];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationTransition:transition forView:self.view cache:YES];
[UIView commitAnimations];*/
CATransition* theTransition = [CATransition animation];
theTransition.duration = 0.6;
theTransition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
theTransition.type = kCATransitionMoveIn; //kCATransitionMoveIn; //, kCATransitionPush, kCATransitionReveal, kCATransitionFade
theTransition.subtype = kCATransitionFromTop; //kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom
[self.view.layer addAnimation:theTransition forKey:nil];
[self pushViewController:controller animated:NO];
}
- (UIViewController *) popControllerWithTransition: (UIViewAnimationTransition) transition
{
/*
[UIView beginAnimations:nil context:NULL];
UIViewController *vc = [self popViewControllerAnimated:NO];
[UIView setAnimationDuration:.5];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationTransition:transition forView:self.view cache:YES];
[UIView commitAnimations];
*/
CATransition* theTransition = [CATransition animation];
theTransition.duration = 0.6;
theTransition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
theTransition.type = kCATransitionReveal; //kCATransitionMoveIn; //, kCATransitionPush, kCATransitionReveal, kCATransitionFade
theTransition.subtype = kCATransitionFromBottom; //kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom
[self.view.layer addAnimation:theTransition forKey:nil];
UIViewController *vc = [self popViewControllerAnimated:NO];
return vc;
}
@end
Posted on July 1, 2011, in iOS. Bookmark the permalink. Leave a Comment.
Leave a Comment
Comments (0)