2012-04-05 39 views
2

我正在使用我正在使用的應用程序UIScrollview,因爲我需要使用翻頁效果。如何在'UIScrollview`中給頁面翻頁效果?

如何在UIScrollview中給翻頁效果?

注意:在UIScrollView的,當我們在那個時候改變頁面滾動頁面前進後退&。當我們滾動頁面時,是否可以賦予頁面滾動效果?

+1

請更好地解釋你的問題。頁面翻轉效果只能通過PageViewController從iOS 5本地獲得。 UIScrollView不是這樣做的方式。 – shannoga 2012-04-05 05:14:39

+0

在UIScrollview當我們改變頁面的時候向前和向後滾動頁面。可以在我們滾動頁面的時候給頁面滾動效果。 – Mayur 2012-04-05 05:20:43

+0

使用 - (void)scrollViewDidScroll:(UIScrollView *)scrollView;方法並在該方法中執行動畫。確保啓用了尋呼功能。 – HarshIT 2012-04-05 06:17:01

回答

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"; 
[email protected]"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"; 
[email protected]"fromRight"; 
animation.fillMode = kCAFillModeBackwards; 

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

您可以在UIScrollView的代表使用此代碼。

+0

它適用於我感謝priyanka – Mayur 2012-04-09 07:17:59