I made a video demonstrating the animation i'm trying to accomplish: Here it is.
Notice the video illustrates the action as it would be seen from the side. The camera icon represents the user's POV. It's basically a simulation of a translation among the Z-axis accomplished though a scale transform, with a simultaneous independent two-step 3D rotation happening along the X axis.
Looks and sounds simple enough, right? Wrong. Here's the ideal code, which doesn't work:
[UIView animateWithDuration:0.4 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
view.transform = CGAffineTransformMakeScale(1.0, 1.0);
} completion:^(BOOL finished) {}];
[UIView animateWithDuration:0.2 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
CATransform3D rotation = CATransform3DIdentity;
rotation.m34 = 1.0 / - 1800;
rotation = CATransform3DRotate(rotation, - 20 * M_PI / 180.0f, 1, 0, 0);
view.layer.transform = rotation;
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.2 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
view.layer.transform = CATransform3DIdentity;
} completion:^(BOOL finished) {}];
}];
Turns out, if you do this, the 3D rotation gets ignored completely. I've tried a number of other approaches, and they all have failed.
Some requirements:
- Scale should preferably be a
CGAffineTransform
- Easings should be as illustrated, especially on the rotation
Of course, if a solution comes up that requires some of these to change, I could adapt.
Thanks in advance for any help. If you need clarification, please do ask.