如何在iOS中使用滑动手势进行页面卷曲? [英] How to do Page Curl with swipe gesture in iOS?

查看:137
本文介绍了如何在iOS中使用滑动手势进行页面卷曲?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在iOS中使用滑动手势进行Page Curl。

I need do Page Curl with swipe gesture in iOS.

我研究过Leaves项目( https:// github .com / brow / leaves ),但它不支持滑动手势。

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 ?

谢谢。

推荐答案

使用UISwipeGestureRecognizer和UIViewAnimationTransition

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];
}

这篇关于如何在iOS中使用滑动手势进行页面卷曲?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆