CATransition Cube with panning gesture

679 Views Asked by At

I'm developing an app which displays four views above a cube which you can roll swiping from right and from left.I've easily realized this interaction using CATransitions like this:

[self.view1 addSubview:nextTo1];
CATransition *animation = [CATransition animation];
[animation setDuration:0.5];
[animation setType:@"cube"];
[animation setSubtype:kCATransitionFromRight];
[animation setTimingFunction:[CAMediaTimingFunctionfunctionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[[self.view1 layer] addAnimation:animation forKey:@"cube"];

Then i've hooked everything with the swipe gesture and everything works well. The problem is that the customer is asking for a Panning gesture, so the cube rotation should follow the finger during the animation and i really don't know how to implement it without for example OpenGL (that could become much more expensive that simple transitions). Is there a way to have more control over CATransitions or some view distortion function that i can use to solve this issue?

Thank you very much and merry Christmas!!

1

There are 1 best solutions below

0
On

One way of doing this is by setting layer.speed to zero (so that the animation doesn't move by itself), and setting layer.timeOffset based on movement from your pan gesture recognizer. Setting the timeOffset controls the animation's progress, when timeOffset reaches the animation duration, it's 100% complete.

An example of this has been posted in the answer to another question: https://stackoverflow.com/a/22652663/209855