Question

I am trying to understand how to get the bookcover open and close animation going in ios. Google search resulted this:

coverimage.layer.anchorPoint=CGPointMake(0, .5);
coverimage.center = CGPointMake(coverimage.center.x - coverimage.bounds.size.width/2.0f, coverimage.center.y);
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationDelay:0.1];
coverimage.transform = CGAffineTransformMakeTranslation(0,0);
CATransform3D _3Dt = CATransform3DIdentity;
_3Dt = CATransform3DMakeRotation(3.141f/2.0f,0.0f,-1.0f,0.0f);
_3Dt.m34 = 0.001f;
_3Dt.m14 = -0.0015f;
coverimage.layer.transform =_3Dt;
[UIView commitAnimations];

It works great, but I am finding it hard to understand how it does the CATransform3DMakeRotation. If any direction or resources you have come across please let me know. My main motive is find a way so it reverses the action (Close the cover of the book). I have tried changing the code but didn't work. Thanks in advance.

Was it helpful?

Solution

Download the sample and follow the simple execution of the desired output from library - Flip Animation

Above library supports 3 interaction modes:

  1. Triggered: as in a tap to flip
  2. Auto: as in a revolving flip that loops through data
  3. Controlled: as in a pan gesture that moves the flip layer according to touch
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top