Use a custom transition, to extend the image view from the initial preview size to full screen. When called, return a transition delegate from transitioningDelegate
, which in turn should return an animation controller from animationControllerForPresentedController:presentingController:sourceController:
. This animation controller will be responsible for the animation that will be performed when presentViewController:animated:completion:
is called.
In your animation controller, implement and in it, create the animation:
- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext
{
UIViewController* toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
MyChatViewController* fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
[[transitionContext containerView] addSubview:toViewController.view];
toViewController.view.frame = [transitionContext.containerView convertRect:fromViewController.imageViewToTransitionFrom.frame fromView:fromViewController.imageViewToTransitionFrom];
[UIView animateWithDuration:[self transitionDuration:transitionContext] animations:^{
toViewController.view.frame = [transitionContext finalFrameForViewController:toViewController];
} completion:^(BOOL finished) {
[transitionContext completeTransition:![transitionContext transitionWasCancelled]];
}];
}
Here, MyChatViewController
is your chat view controller and imageViewToTransitionFrom
holds the image view you wish to transition from.
If you need to push a view controller instead of present it (like WhatsApp does it), there are analogous methods to perform the custom push animation.
You can perform a dismiss/pop animation in a similar manner, or use the default system one.
Read here about custom view controller transitions in iOS7.