gpt4 book ai didi

iphone - 如何在 iOS 中通过滑动手势实现卷页?

转载 作者:行者123 更新时间:2023-12-03 19:39:33 25 4
gpt4 key购买 nike

我需要在 iOS 中使用滑动手势进行卷页。

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

有人成功地用滑动手势实现了卷页吗?

谢谢。

最佳答案

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

关于iphone - 如何在 iOS 中通过滑动手势实现卷页?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5819897/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com