popViewControllerAnimated:自定义过渡动画? [英] popViewControllerAnimated: custom transition animation?

查看:54
本文介绍了popViewControllerAnimated:自定义过渡动画?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是的,我已经在寻找答案了.除了不提供淡入淡出过渡选项,仅提供翻转或卷曲的解决方案外,所有解决方案均无效.

Yes, I have looked for an answer already. None of the solutions work, except one that doesn't give the option for a fade transition, only flip or curl.

像这样:

methodname
    configure animation
    [self.navigationController popViewControllerAnimated:NO];

无论我尝试什么样的过渡动画配置,都与仅使用典型的单行 pop 没有明显不同.如果我将其更改为 ...Animated:YES];,我会得到标准的流行动画,可能是由于损坏的配置发生了一些奇怪的事情.

No matter what variety of transition animation config I try, nothing is visibly different from only using the typical single-line pop. If I change it to …Animated:YES];, I get the standard pop animation, maybe with something weird happening from the broken config.

所以我的问题是这样的:如果不是 CrossDissolve,我怎样才能做一个 pop,然后至少看起来相同的东西?导航控制器甚至可以做到这一点吗?

So my question is this: How can I do a pop with, if not CrossDissolve, then at least something that looks the same? Is that even possible with a navigation controller?

使用模态视图可以获得我想要的默认动画,而且我可以很容易地管理视图堆栈,但我不想那样做.

Using modal views would have the default animation I want, and I could manage the view stack easily enough, but I don't want to do that.

推荐答案

对于这种类型的过渡,我真的会推荐一个模态视图控制器,这就是系统的设计方式.

For this type of transition I would really recommend a modal view controller, thats the way the system was designed.

但如果你坚持使用导航控制器,有一种方法,虽然有点难看.

But if you insist on using the navigation controller there is a way, though somewhat ugly.

[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];

CATransition *transition = [CATransition animation];
[transition setType:kCATransitionFade];
[self.navigationController.view.layer addAnimation:transition forKey:@"someAnimation"];

[self.navigationController popViewControllerAnimated:YES];
[CATransaction commit];

CATransaction 将禁用所有标准动画.CATransition 在交换视图时向导航控制器层添加淡入淡出过渡(在这种情况下删除弹出的视图控制器视图).

The CATransaction will disable all standard animations. The CATransition adds a fade transition to the navigation controller layer when views are swapped (in this case removing the viewcontroller view that is popped).

这篇关于popViewControllerAnimated:自定义过渡动画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆