Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do Page Curl with swipe gesture in iOS?

Tags:

iphone

ipad

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.

like image 965
user403015 Avatar asked Jan 27 '26 16:01

user403015


1 Answers

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];
}
like image 167
puppybits Avatar answered Jan 30 '26 11:01

puppybits



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!