我需要在iOS上使用滑动手势实现翻页效果。
我已经研究了Leaves项目(https://github.com/brow/leaves),但它不支持滑动手势。
有人成功地使用滑动手势实现了翻页效果吗?
谢谢。
我需要在iOS上使用滑动手势实现翻页效果。
我已经研究了Leaves项目(https://github.com/brow/leaves),但它不支持滑动手势。
有人成功地使用滑动手势实现了翻页效果吗?
谢谢。
- (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];
}
对于页面翻页效果,您可以使用视图转换动画实现。对于滑动手势,请查看使用新的手势识别器类。您还可以设置过渡样式,在呈现新的模态视图控制器时获取其他过渡样式。