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

May*_*yur 2 iphone objective-c ipad

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

我怎样才能提供Page翻转效果UIScrollview

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

pri*_*nka 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"];
Run Code Online (Sandbox Code Playgroud)

向后翻转 -

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"]; 
Run Code Online (Sandbox Code Playgroud)

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