部分页面翻页动画

13

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

4个回答

11
在iOS 3.2及更高版本中,你可以为你的UIViewController设置UIModalTransitionStylePartialCurlUIModalTransitionStyle。从UIViewController参考文献中可以看到。
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
如果您想这样做,但是要保留底部工具栏(例如,不是全屏卷曲),请查看我的解决方案此处 - Tim Arnold

7
我找到了一种方法,可以使用动画块将UIView添加到UIViewController中。
m_Container是一个包含我的视图动画(self)的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吗?它似乎运行得很完美,但我在文档中找不到它。 - SG1
这不是私有API,我只是使用UIView方法来动画化一个视图(对我来说是m_container)。你只需要复制方法内容到自己的方法中,并将m_container更改为你的视图... - TheRonin

1

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


好知道...我猜我只能做一个页面翻转过渡了。 - rson
从iOS 3.2开始,这不再是真的。 - tJener

0

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


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