2009-11-05 68 views
11

我有一個使用UIViewAnimationTransitionCurlUp的工作過渡,但是我希望動畫能夠中途停止,就像地圖應用程序一樣......有關如何實現這一點的任何想法?部分頁面捲曲動畫

回答

1

地圖部分捲曲是一個私人API。您可以在Erica Sadun的書The iPhone Developer's Cookbook中找到如何使用它的詳細信息,但是您將被App Store拒絕使用它。

+0

好知道...猜猜我只是做一個頁面翻轉過渡然後。 – rson 2009-11-05 20:47:00

+0

從iOS 3.2開始,這不再是事實。 – tJener 2011-03-18 03:48:00

0

不確定這是否可行,但+setAnimationRepeatCount:的參數可以是分數。

+0

如果我這樣做,那麼過渡與視圖消失... – rson 2009-11-05 20:38:57

11

在iOS 3.2及更高版本中,您可以將UIViewController設爲UIModalTransitionStyleUIModalTransitionStylePartialCurl。從UIViewControllerreference,我們看到

typedef enum { 
    UIModalTransitionStyleCoverVertical = 0, 
    UIModalTransitionStyleFlipHorizontal, 
    UIModalTransitionStyleCrossDissolve, 
    UIModalTransitionStylePartialCurl, 
} UIModalTransitionStyle; 

所以一個例子使用的情況將是:

UIViewController *viewController; 
// …create or retrieve your view controller… 

// Note: The modalPresentationStyle must be UIModalPresentationFullScreen, 
//  and the presenter must also be a full-screen view 
viewController.modalPresentationStyle = UIModalPresentationFullScreen; 
viewController.modalTransitionStyle = UIModalTransitionStylePartialCurl; 
+1

如果你想這樣做,但保留一個底部工具欄(例如,不是全屏捲曲),請參閱我的解決方案[這裏](http://stackoverflow.com/a/11406056/1148702) – 2012-07-10 14:53:13

7

我找到了一個解決方案使用動畫塊UIView的一個要添加到的UIViewController。

m_Container是包含我的視圖動畫(自我)的UIView。 自己是一個UIView。

注意:您需要有進口QuartzCore

要與頁面捲曲動畫現在的看法,你可以使用:

-(void)PresentView 
{ 
    [UIView animateWithDuration:1.0 
        animations:^{ 
         CATransition *animation = [CATransition animation]; 
         [animation setDelegate:self]; 
         [animation setDuration:0.7]; 
         [animation setTimingFunction:UIViewAnimationCurveEaseInOut]; 
         animation.type = @"pageCurl"; 
         animation.fillMode = kCAFillModeForwards; 
         animation.endProgress = 0.65; 
         [animation setRemovedOnCompletion:NO]; 
         [m_container.layer addAnimation:animation forKey:@"pageCurlAnimation"]; 
         [m_container addSubview:self]; 
         ;} 
    ];  
} 

當你想隱藏這個觀點,你可以使用:

-(void)HideHelpView 
{ 
    [UIView animateWithDuration:1.0 
        animations:^{ 
         CATransition *animation = [CATransition animation]; 
         [animation setDelegate:self]; 
         [animation setDuration:0.7]; 
         [animation setTimingFunction:UIViewAnimationCurveEaseInOut]; 
         animation.type = @"pageUnCurl"; 
         animation.fillMode = kCAFillModeForwards; 
         animation.startProgress = 0.35; 
         [animation setRemovedOnCompletion:NO]; 
         [m_container.layer addAnimation:animation forKey:@"pageUnCurlAnimation"]; 
         [self removeFromSuperview]; 

         ;} 
    ]; 

} 

我希望我幫你。

+0

這是私人API?它似乎工作完美,但我沒有看到它在文檔中。 – SG1 2012-02-12 18:41:03

+0

這不是一個私人的API,我只是使用UIView方法爲視圖設置動畫效果(m_container)。你只需要在你自己的方法中複製方法內容,並通過你的視圖改變m_container ... – TheRonin 2012-02-13 09:20:19