0

我正在尝试通过使用下面的代码片段来实现卷曲效果

卷曲

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.95];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown
 forView:self.view cache:YES];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
[UIView setAnimationDelegate:self];

卷起

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.95];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
[UIView setAnimationDelegate:self];

但这适用于纵向模式。

我想在横向模式下实现它,点击右上角和左下角。

目前它的工作是相反的。

非常感谢

4

2 回答 2

2
#import <QuartzCore/QuartzCore.h>

-(void)pageCurltoNextorPrevious:(UIView*)view:(int)identifier {

// Curl the image up or down
CATransition *animation = [CATransition animation];
[animation setDelegate:self];
[animation setDuration:1.0];
CAMediaTimingFunction *fun=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
[animation setTimingFunction:fun];


if (identifier==1){
    //next animation
    animation.type = @"pageCurl";
    animation.subtype=@"fromRight";
    animation.fillMode = kCAFillModeForwards;
    animation.endProgress = 1.0; //0.58;
} 
else {
    //previous animation
    animation.type = @"pageCurl";
    animation.subtype=@"fromLeft";
    animation.fillMode = kCAFillModeBackwards;
    animation.startProgress = 0.0;
}
[animation setRemovedOnCompletion:NO];

//[view exchangeSubviewAtIndex:0 withSubviewAtIndex:2];

[[view layer] addAnimation:animation forKey:@"pageCurlAnimation"];
}
于 2012-05-08T06:44:16.243 回答
1

请尝试这种方式。我在一个视图的视图导航中使用

下一个视图的第一个视图 Infoview 我创建了 curlup 效果:

InfoView *objdb=[[InfoView alloc] initWithNibName:@"InfoView" bundle:nil];
[UIView beginAnimations:nil context:NULL ];
[UIView setAnimationCurve:UIViewAnimationTransitionCurlUp];
[UIView setAnimationDuration:1.0];
[self presentModalViewController:objdb animated:YES];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
[objdb release];

然后从 infoview 回到主视图然后使用这个(卷曲效果):

[UIView  beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationTransitionCurlDown];
[UIView setAnimationDuration:0.75];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelay:0.375];
[self dismissModalViewControllerAnimated:YES];
[UIView commitAnimations];

我希望它对你有帮助。

于 2012-05-10T06:11:59.727 回答