I need do Page Curl with swipe gesture in iOS.
I have studied the Leaves project ( https://github.com/brow/leaves ), but it does not support swipe gesture.
Did anyone successfully implement page curl with swipe gesture ?
Thanks.
I need do Page Curl with swipe gesture in iOS.
I have studied the Leaves project ( https://github.com/brow/leaves ), but it does not support swipe gesture.
Did anyone successfully implement page curl with swipe gesture ?
Thanks.
Use the UISwipeGestureRecognizer and UIViewAnimationTransition
- (void)handleSwipe:(UISwipeGestureRecognizer *)sender {
if(sender.state == UIGestureRecognizerStateEnded) {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:window cache:YES];
[self.view addSubview:[newView view]];
[oldView removeFromSuperview];
[UIView commitAnimations];
}
}
- (void)createGestureRecognizers:(UIView *) target {
UISwipeGestureRecognizer *rightSwipeRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipe:)];
[rightSwipeRecognizer setDirection:(UISwipeGestureRecognizerDirectionRight)];
[target addGestureRecognizer:rightSwipeRecognizer];
[rightSwipeRecognizer release];
}
Use the UISwipeGestureRecognizer. Not much else to say really, gesture recognizers are easy. There are WWDC10 videos on the subject even. Sessions 120 and 121
Apple certainly uses OpenGL ES to implement it. The actual API Apple uses is private, but this blogger has the starting of an implementation with sample code. So now you're few clicks away to perform page curl inside the customize swipe gesture.
For page curl, you can do it using a view transition animation. For swipe gesture, look at using the new gesture recognizer classes. You can also set the transition style for when you present a new modal view controller to get some other transition styles.
I don't know about the page curl aspect and I'm not familiar with Leaves, but you could take a look at the UISwipeGestureRecognizer
class documentation for more information there. Perhaps you can extend the Leaves source code.