在推送 UINavigationController 时为 UIView 制作动画
以下情况。 我有一个使用 UINavigationController 进行导航的应用程序。
为了推动特殊的导航控制器,我想要一个自定义动画,一个缩小。 到目前为止,我所拥有的看起来不错,唯一的问题是,“旧”视图控制器在动画开始之前消失,因此新视图控制器会缩小“无”,而不是在后台查看旧视图控制器。
为了更好地观看,我创建了一个简单的示例应用程序: 下载
有谁知道如何为旧视图控制器(image1) 的新视图控制器(image3) 制作动画动画时留在后台(图 2)?
/* THIS CANNOT BE CHANGED */
AnimatedViewController *animatedViewController = [[AnimatedViewController alloc] initWithNibName:@"AnimatedViewController" bundle:nil];
/* THIS CAN BE CHANGED */
animatedViewController.view.transform = CGAffineTransformMakeScale(0.01, 0.01);
[UIView beginAnimations:@"animationExpand" context:NULL];
[UIView setAnimationDuration:0.6f];
animatedViewController.view.transform=CGAffineTransformMakeScale(1, 1);
[UIView setAnimationDelegate:self];
[UIView commitAnimations];
/* THIS CANNOT BE CHANGED */
[self.navigationController pushViewController:animatedViewController animated:NO];
附加信息:我的应用程序并不那么简单。我在我的应用程序中使用 Three20 框架,但是视图控制器的推送和创建就是 Three20 所做的。我只能连接到(THIS CAN BE CHANGED
在我的代码中)之间的部分。我无法在此之前和之后更改代码(除非进行大量研究)。
following situation.
i have an app that uses a UINavigationController for navigating.
For a push of a special Navigation Controller i want a custom Animation, a zoom out.
What i have is looking good so far, the only problem is, that the "old" Viewcontroller disappears before the animation starts, so the new viewcontroller zooms out of "nothing" instead of viewing the old viewcontroller in the background.
For better viewing i created a simple sample app: download
Does anybody know, how to animate the new viewcontroller (image3) that the old view controller(image1) stays in the background while animating (image 2)?
/* THIS CANNOT BE CHANGED */
AnimatedViewController *animatedViewController = [[AnimatedViewController alloc] initWithNibName:@"AnimatedViewController" bundle:nil];
/* THIS CAN BE CHANGED */
animatedViewController.view.transform = CGAffineTransformMakeScale(0.01, 0.01);
[UIView beginAnimations:@"animationExpand" context:NULL];
[UIView setAnimationDuration:0.6f];
animatedViewController.view.transform=CGAffineTransformMakeScale(1, 1);
[UIView setAnimationDelegate:self];
[UIView commitAnimations];
/* THIS CANNOT BE CHANGED */
[self.navigationController pushViewController:animatedViewController animated:NO];
Additional information: my app isn't that simple. i use three20 framework for my app but the pushing and creating of the view controllers is simply what three20 does. i only can hook into the part between (THIS CAN BE CHANGED
in my code). i cannot change the code before and after this (except with a lot of researching).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我很快就想到了这个。想法是在缩放动画完成后调用pushViewController。
I whipped this up very quickly. The idea is to call pushViewController after the scale animation is completed.
好的,一种方法(有点难看)是执行动画,并在动画完成后执行pushViewController。当您制作动画时,您需要对即将呈现的视图控制器的屏幕进行动画处理。由于动画以新视图结束,因此当新视图出现在屏幕上时,不应发生任何变化,因为它与刚刚动画的视图相同。
Ok, one way to do this (a bit ugly) is to do the animation and upon the completion of the animation, do the pushViewController. When you do the animation, you need to animate up what the about-to-be-presented view controller's screen would look like. Since the animation ends with the new view, when the new view comes to the screen, nothing should change because its the same as the just animated view.