如何在“UIScrollview”中提供Page翻转效果?

时间:2012-04-05 05:11:52

标签: iphone objective-c ipad

我正在处理我正在使用UIScrollview的应用程序,因为我需要使用页面翻转效果。

如何在UIScrollview中提供页面翻转效果?

注意:当我们在那时更改Page时,在UIScrollview中滚动页面向前和向前滚动向后。可以在我们滚动页面时给出页面滚动效果吗?

1 个答案:

答案 0 :(得分:7)

前进翻转 -

CATransition *animation = [CATransition animation];
[animation setDelegate:self];
[animation setDuration:1.0f];
animation.startProgress = 0;
animation.endProgress   = 1;
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
animation.type = @"pageCurl";
animation.subtype=@"fromRight";
animation.fillMode = kCAFillModeForwards;

[animation setRemovedOnCompletion:NO];
[animation setFillMode: @"extended"];
[animation setRemovedOnCompletion: NO];
[lyr addAnimation:animation forKey:@"WebPageCurl"];

向后翻转 -

CATransition *animation = [CATransition animation];
[animation setDelegate:self];
[animation setDuration:1.5f];
animation.startProgress = 0;
animation.endProgress   = 1;
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
animation.type = @"pageUnCurl";
animation.subtype=@"fromRight";
animation.fillMode = kCAFillModeBackwards;

[animation setRemovedOnCompletion:NO];
[animation setFillMode: @"extended"];
[animation setRemovedOnCompletion: NO];
[lyr addAnimation:animation forKey:@"WebPageCurl"]; 

您可以在UIScrollView委托时使用此代码。