【发布时间】:2010-12-13 11:18:34
【问题描述】:
我有一个使用 UIViewAnimationTransitionCurlUp 的工作过渡,但是,我希望动画在中途停止,就像地图应用程序一样...关于如何实现这一点的任何想法?
【问题讨论】:
标签: iphone curl transition
我有一个使用 UIViewAnimationTransitionCurlUp 的工作过渡,但是,我希望动画在中途停止,就像地图应用程序一样...关于如何实现这一点的任何想法?
【问题讨论】:
标签: iphone curl transition
在 iOS 3.2 及更高版本中,您可以将 UIViewController 指定为 UIModalTransitionStyle 或 UIModalTransitionStylePartialCurl。从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;
【讨论】:
我找到了使用动画块将 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。你可以在 Erica Sadun 的书The iPhone Developer's Cookbook 中找到如何使用它的详细信息,但你会因为使用它而被 App Store 拒绝。
【讨论】:
不确定这是否可行,但+setAnimationRepeatCount: 的参数可以是一个分数。
【讨论】: