2

我正在写一个绘图应用程序,当用户点击工具栏中的一个项目时显示一个工具视图控制器。但是,我的几位测试者已经报告说,工具上腭的打开速度太慢。我使用的是标准的presentModalViewController:动画:来电显示的工具,我已经试过它包裹在这样的代码块加快步伐:我可以增加presentModalViewController的动画速度吗?

[UIView beginAnimations:nil context:nil]; 
[UIView setAnimationDuration: 0.1]; 
[self presentModalViewController:settings animated:YES]; 
[UIView commitAnimations]; 

不幸的是,这是行不通的。如果你说动画:NO,它会更好,但底层绘图画布视图立即被移除(因为控制器认为它不再可见),所以动画发生在白色背景上。

以前有没有人愿意提供一些建议?我会很感激!

回答

1

有类似的问题要求here

您也可以使用此技术更改速度,但在我的实验中,它是在空白背景下完成的,如您所建议的。

+0

感谢您的提示zpasternack - 我会检查出来! – 2009-06-29 06:15:25

+0

看起来像这样,就像它会得到。答案接受:-) – 2009-07-12 00:22:28

8

编辑:增加了另一个选项与控制器遏制iOS 5和更高版本。

另一种解决方法是设置图层的时间空间。

这是通过CALayer的速度属性完成的。为了减缓动画下来,可以使用:

MytransparentVCViewController *vc = [[MytransparentVCViewController alloc] initWithNibName:@"MytransparentVCViewController" bundle:nil]; 
// Makes all animations 10 times slower 
// To speed it up, set it to multiples of 1: 2 is 2 times faster, 3 is 3 times faster etc 
vc.view.layer.speed = 0.1; 
[self presentModalViewController:vc animated:YES]; 

注意,如果你的目标是要改变模式视图控制器,你将要呈现的动画速度在链接后所提出的解决方案将无法正常工作(为例如,如果您使用UIModalTransitionStyleCoverVertical)。

图层的速度不是绝对值,而是该图层父级时间空间的函数(除非图层位于图层层次结构的根目录中)。例如,当您将图层的速度设置为2时,与该图层父级的动画相比,其动画运行速度会快两倍。

另一种选择是使用视图控制器遏制。 (仅适用于iOS 5及更高版本)

http://developer.apple.com/library/ios/DOCUMENTATION/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006926-CH3-SW81

您可以使用UIViewController的transitionFromViewController完全控制动画:toViewController:duration:options:animations:completion :.