【问题标题】:Partial page curl animation部分卷页动画
【发布时间】:2010-12-13 11:18:34
【问题描述】:

我有一个使用 UIViewAnimationTransitionCurlUp 的工作过渡,但是,我希望动画在中途停止,就像地图应用程序一样...关于如何实现这一点的任何想法?

【问题讨论】:

    标签: iphone curl transition


    【解决方案1】:

    在 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;
    

    【讨论】:

    • 如果您想这样做,但保留底部工具栏(例如,不是全屏卷曲),请参阅我的解决方案 here
    【解决方案2】:

    我找到了使用动画块将 UIView 添加到 UIViewController 的解决方案。

    m_Container 是一个包含我的视图动画(自我)的 UIView。 self 是一个 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];
    
                             ;}  
         ];
    
    }
    

    【讨论】:

    • 这是私有 API 吗?它似乎工作得很好,但我没有在文档中看到它。
    • 这不是私有 API,我只是使用 UIView 方法为视图设置动画(对我来说是 m_container)。您只需将方法内容复制到您自己的方法中并根据您的视图更改 m_container...
    【解决方案3】:

    地图部分卷曲是一个私有 API。你可以在 Erica Sadun 的书The iPhone Developer's Cookbook 中找到如何使用它的详细信息,但你会因为使用它而被 App Store 拒绝。

    【讨论】:

    • 很高兴知道...我想我会做一个翻页过渡。
    • 从 iOS 3.2 开始,这不再适用。
    【解决方案4】:

    不确定这是否可行,但+setAnimationRepeatCount: 的参数可以是一个分数。

    【讨论】:

      猜你喜欢
      • 2012-08-18
      • 2011-03-02
      • 2015-06-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多