Question

I am trying to create a custom UIView transition. Basically when a certain modal view is presented then the views it is covering up move into the background.

To achieve this I am using Core animation to manipulate the CATransform3D on the layer of the view I am moving to the background then presenting the modal view on top of that.

To move the view into the background I am creating a CABasicAnimation to animate the change in the CATransform3D like this

CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform"];

CATransform3D toTransform = CATransform3DIdentity;
toTransform.m34 = 1.0f / -500.0f;
toTransform = CATransform3DTranslate(toTransform, 0.0f, 0.0f, -40.0f);

[animation setFromValue:[NSValue valueWithCATransform3D:CATransform3DIdentity]];
[animation setToValue:[NSValue valueWithCATransform3D:toTransform]];
[animation setDuration:1.0f];

self.menuView.layer.transform = toTransform;
[self.menuView.layer addAnimation:animation forKey:@"moveBackAnimation];

self.menuView is the view I am moving back.

This works great until I add in the modal view.

RVLAddViewController *addViewController = [[RVLAddViewController alloc] initWithNibName:@"RVLAddViewController" bundle:nil];
[self presentViewController:addViewController animated:YES completion:nil];

I call this code right under the animation when a button is pressed.If this code isn't present them every thing works as expected the view looks like it is just fading into the distance and then it stays there.

When the modal view is presented then instead of gradually fading into the distance, it shoots down to the smaller size and moves into the top left hand corner.

I'll upload a sample application as soon as I can, github is down right now. edit No need -a solution has been given! /edit

Was it helpful?

Solution

I messed around with this for a while, and it looks like it has to do with auto layout. If you turn that off, it works as you would expect.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top