PUSH
SecondViewController *second=[[SecondViewController alloc]initWithNibName:nil bundle:nil];
UINavigationController *nav=[[UINavigationController alloc]initWithRootViewController:second];
CGRect destFrame = nav.view.frame;
destFrame.origin.x = nav.view.frame.size.width;
nav.view.frame = destFrame;
destFrame.origin.x = 0;
[self.view addSubview:nav.view];
[UIView animateWithDuration:0.25
animations:^{
nav.view.frame = destFrame;
}
completion:^(BOOL finished) {
[self.navigationController presentViewController:nav animated:NO completion:nil];
}];
POP
-(void)btnAction:(id)sender
{
[self.navigationController.view.layer addAnimation:[self getPopAnimation] forKey:nil];
self.navigationController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
}
-(CATransition*)getPopAnimation
{
CATransition *transition = [CATransition animation];
transition.duration = 0.5f;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromLeft;
return transition;
}