我该如何在 `UIScrollview` 中实现翻页效果?

3

我正在开发一个应用程序,其中使用了UIScrollview,我需要使用页面翻转效果。

如何在UIScrollview中实现页面翻转效果呢?

注意:在UIScrollview中,当我们更改页面时,同时也在向前或向后滚动页面。在页面滚动时是否可以实现页面滚动效果呢?


1
请更好地解释你的问题。翻页效果仅在iOS 5中通过PageViewController本地提供。UIScrollView不是实现该效果的正确方式。 - shannoga
在UIScrollView中,当我们切换页面时,会向前和向后滚动页面。是否可能在滚动页面时同时给出页面滚动效果? - Mayur Prajapati
使用 - (void)scrollViewDidScroll:(UIScrollView *)scrollView; 方法,在此方法中执行动画。确保启用分页功能。 - HarshIT
1个回答

8
前置翻转 -
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的代理时,您可以使用此代码。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接