繁体   English   中英

如何在 iOS 中使用滑动手势页面 Curl?

[英]How to do Page Curl with swipe gesture in iOS?

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

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

有人用滑动手势成功实现页面 curl 吗?

谢谢。

使用 UISwipeGestureRecognizer 和 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];
}

使用 UISwipeGestureRecognizer。 真的没什么好说的,手势识别器很容易。 甚至还有关于这个主题的 WWDC10 视频。 会议 120 和 121

苹果当然使用 OpenGL ES 来实现它。 苹果使用的实际 API 是私有的,但是这个博主已经开始使用示例代码实现。 因此,现在您只需单击几下即可在自定义滑动手势中执行页面 curl。

对于页面 curl,您可以使用视图转换 animation 来完成。 对于滑动手势,请查看使用新的手势识别器类。 您还可以在呈现新的模态视图 controller 时设置转换样式,以获得其他一些转换 styles。

我不知道页面 curl 方面,我不熟悉叶子,但您可以查看UISwipeGestureRecognizer class 文档以获取更多信息。 也许您可以扩展 Leaves 源代码。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM