I finally ended up doing a mix with these two:
In vcB:
-(id<UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController animationControllerForOperation:(UINavigationControllerOperation)operation fromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC
{
if (operation == UINavigationControllerOperationPush || operation == UINavigationControllerOperationPop) {
MyAnimator *animator = [[MyAnimator alloc] init];
animator.presenting = (operation == UINavigationControllerOperationPush);
return animator;
}
return nil;
}
In MyAnimator.m:
-(NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext
{
return 0.4;
}
-(void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext
{
UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
[[transitionContext containerView] addSubview:toViewController.view];
CGRect currentFrame = toViewController.view.frame;
CGRect toFrameInitial = self.presenting ? CGRectOffset(currentFrame, 0, CGRectGetHeight(currentFrame)) : CGRectOffset(currentFrame, 0, -CGRectGetHeight(currentFrame));
CGRect fromFrameFinal = self.presenting ? CGRectOffset(currentFrame, 0, -CGRectGetHeight(currentFrame)) : CGRectOffset(currentFrame, 0, CGRectGetHeight(currentFrame));
toViewController.view.frame = toFrameInitial;
[UIView animateWithDuration:[self transitionDuration:transitionContext] animations:^{
toViewController.view.frame = currentFrame;
fromViewController.view.frame = fromFrameFinal;
} completion:^(BOOL finished) {
[transitionContext completeTransition:![transitionContext transitionWasCancelled]];
}];
}