我可以提高presentModalViewController的动画速度吗?

Ben*_*tow 4 iphone core-animation objective-c uinavigationcontroller

我正在编写一个绘图应用程序,当用户单击工具栏中的项目时,该应用程序显示工具视图控制器.但是,我的几位测试人员报告说,工具的味道打开得太慢.我正在使用标准的presentModalViewController:animated:call来显示工具,我尝试将它包装在这样的代码块中以加快速度:

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration: 0.1];
[self presentModalViewController:settings animated:YES];
[UIView commitAnimations];
Run Code Online (Sandbox Code Playgroud)

不幸的是,这不起作用.如果你说动画:不是它效果更好,但是底层绘图画布视图会被立即删除(因为控制器认为它不再可见),因此动画发生在白色背景上.

有没有人在此之前愿意提供一些建议呢?我很感激!

Ang*_*raX 12

已编辑:为iOS 5及更高版本添加了控制器包含的另一个选项.

另一种解决方案是设置图层的时间空间.

这是通过CALayer的speed属性完成的.要减慢动画速度,可以使用:

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];
Run Code Online (Sandbox Code Playgroud)

请注意,如果您的目标是更改要将要呈现的模态视图控制器的动画速度(例如,如果您使用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:.


zpa*_*ack 1

这里提出了类似的问题。

您还可以使用此技术更改速度,但在我的实验中,它是在空白背景上进行的,正如您所建议的那样。