Pergunta

I'm creating a custom push transition (UINavigationController) from one view controller to a view controller who's view is transparent with blur.

I want the "from" view controller to remain visible beneath the newly pushed view controller.

I know I can achieve this effect if presenting the new view controller modally (using modalPresentationStyle = UIModalPresentationCustom), however is there a way to do this for a navigation controller?

The problem I am facing is that the from view controller's view is being removed from the container after the transition takes place.

Foi útil?

Solução

using the new iOS 7 transitioning API's, you cannot keep the fromViewController.view under the toViewController.view as the containerView is managed privately once the animation has finished.

What you can do however is something like this...

UIView *containerView = [transitionContext containerView];

UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];

UIView *snapshotView = [fromViewController.view snapshotViewAfterScreenUpdates:NO];

[toViewController.view addSubview:snapshotView];
[toViewController.view sendSubviewToBack:snapshotView];

I'm not too sure how well the last two lines will work (sending the snapshot to the back) but you could use a custom UIViewController subclass that can handle the snapshot and ensure that it is behind the rest of your content.


After re-reading.. I have a feeling you want to achieve some form of modal rather than a full screen presentation... My above solution would require that the toViewController is full screen... maybe you could then add a child view controller to the toViewController that actually houses the modal content?

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top