Search code examples
iphonecore-animationcalayer

Iphone: Page flipping animation


My code is flipping my view as if you were reading a book in reverse page order (right to left). I'm trying to achieve the opposite but I can't seem to figure out how to make the page flip from the other side of the views coordinate system.

Here's my code:

_memoryOneView.layer.anchorPoint = CGPointMake(1.0f, .5f);
_memoryOneView.layer.position = CGPointMake(_memoryOneView.layer.position.x + _memoryOneView.bounds.size.width/2.0f, _memoryOneView.layer.position.y);

[UIView animateWithDuration:.5 animations:^{
    _memoryOneView.layer.transform = CATransform3DMakeRotation((M_PI / 2.0), 0, 1.0f, 0);
}];

I've tried making many of the values negative but this simply hides the animation behind views behind it. Any ideas? ty.

Edit I also need to be able to use this animation for dragging, meaning I need to have something I can easily transfer into code where the user is dragging to the next page.


Solution

  • iOS 5 has an in-built PageViewController exactly for this. Tutorial here: http://www.techotopia.com/index.php/An_Example_iOS_5_iPhone_UIPageViewController_Application