更新时间:2023-02-26 21:40:07
使用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];
}