卷曲对景观模式的影响

时间:2012-05-06 04:56:38

标签: iphone ios ipad

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

向下卷曲

[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];

但这适用于纵向模式。

我想在横向模式下实现它,在右上角和左下角进行编辑。

目前正在逆向工作。

非常感谢

2 个答案:

答案 0 :(得分: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"];
}

答案 1 :(得分:1)

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

第一个视图下一个Infoview我创建了卷曲效果:

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];

我希望对你有所帮助。