部分页面卷曲动画

时间:2009-11-05 15:33:30

标签: iphone curl transition

我使用UIViewAnimationTransitionCurlUp进行了工作转换但是,我希望动画停止一半,就像地图应用程序一样......有关如何实现这一点的想法吗?

4 个答案:

答案 0 :(得分:11)

在iOS 3.2及更高版本中,您可以为UIViewController UIModalTransitionStyle UIModalTransitionStylePartialCurl提供UIViewController。从typedef enum { UIModalTransitionStyleCoverVertical = 0, UIModalTransitionStyleFlipHorizontal, UIModalTransitionStyleCrossDissolve, UIModalTransitionStylePartialCurl, } UIModalTransitionStyle; reference开始,我们看到

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}}

答案 1 :(得分:7)

我找到了一个使用Animation块将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];

                         ;}  
     ];

}

答案 2 :(得分:1)

Maps partial curl是一个私有API。你可以在Erica Sadun的书The iPhone Developer's Cookbook中找到如何使用它的详细信息,但是你会被App Store拒绝使用它。

答案 3 :(得分:0)

不确定这是否有效,但+setAnimationRepeatCount:的参数可以是一小部分。