自定义动画为推进一个UIViewController [英] Custom Animation for Pushing a UIViewController
问题描述
我要显示推视图控制器时,自定义动画:我想实现的东西像一个扩大的动画,这意味着新的观点从一个给定的矩形的扩展,让说[100,100 220380]动画期间全屏幕。
I want to show a custom animation when pushing a view controller: I would like to achieve something like an "expand" animation, that means the new view expands from a given rectangle, lets say [100,100 220,380] during the animation to full screen.
任何建议,从哪里开始,分别的任何文档,教程链接? :)
Any suggestions where to start, respectively any documents, tutorials, links? :)
好吧。我可以使扩大与下面code动画:
Alright. I could make the expand animation with the following code:
if ([coming.view superview] == nil)
[self.view addSubview:coming.view];
coming.view.frame = CGRectMake(160,160,0,0);
[UIView beginAnimations:@"frame" context:nil];
[UIView setAnimationDuration:4];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[coming viewWillAppear:YES];
[going viewWillAppear:YES];
coming.view.frame = CGRectMake(0, 0, 320, 480);
[going viewDidDisappear:YES];
[coming viewDidAppear:YES];
[UIView commitAnimations];
我的看法是正确显示,但遗憾的是没有更新的导航栏。有没有办法做到这一点手动?
My View is properly displayed, but unfortunately the navigation bar is not updated. Is there a way to do that manually?
在code样品,一个函数被调用的所有0.03秒用于更新观念的嬗变。
不幸的是,当推一个的UIViewController
,我不能够调整视图框...我是谁?
In the sample code, a function is called all 0.03 seconds that updates the transformation of the view.
Unfortunately, when pushing a UIViewController
, I am not able to resize the frame of the view ... am I ?
推荐答案
你可以做的是推动下一个视图控制器,但不进行动画处理,像这样:
What you could do is push the next view controller but don't animate it, like so:
[self.navigationController pushViewController:nextController animated:NO];
...然后,在被越来越推在视图控制器,你可以做一个自定义动画的它的视图中使用CoreAnimation。这可能会在是最好做viewDidAppear:(BOOL)动画
法
退房的<一个href=\"http://developer.apple.com/mac/library/documentation/cocoa/Conceptual/CoreAnimation_guide/Articles/AnimatingLayers.html#//apple_ref/doc/uid/TP40006085-SW1\"相对=nofollow>核心动画指南如何真正做动画。在隐动画特别关注一下。
Check out the Core Animation Guide on how to actually do the animation. Look particularly at the implicit animation.
编辑: 更新链接
这篇关于自定义动画为推进一个UIViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!