带有Transition的UIModalPresentationCurrentContext? [英] UIModalPresentationCurrentContext with Transition?

查看:538
本文介绍了带有Transition的UIModalPresentationCurrentContext?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试模态呈现如下所示的视图控制器:

I am trying to modal present a view controller like below:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"addPopover"];
vc.view.backgroundColor = [UIColor clearColor];
self.modalPresentationStyle = UIModalPresentationCurrentContext;
[self presentModalViewController:vc animated:YES];

现在使用 UIModalPresentationCurrentContext 意味着我可以提出这个查看透明背景,看看我新的背后的另一个视图。然而,它阻止我能够通过过渡呈现它。

Now using UIModalPresentationCurrentContext means I can present this view with a transparent background and see my other view behind the new one. However, it stops me from being able to present it with a transition.

任何想法为什么?或者我如何解决这个问题?谢谢。

Any ideas why? Or how I can get around this? Thanks.

推荐答案

全屏模式不允许你看到底层。很烦我知道。

Full screen modals aren't supposed to allow you to see the under layer. Annoying I know.

从你的代码中我假设addPopover实际上是一个全屏视图,你将内容作为一个小节,而其余的是透明的。

From your code I'm assuming that "addPopover" is actually a full screen view, where you have your content as a subsection while the rest is transparent.

试试这个:

vc.modalPresentationStyle = UIModalPresentationCurrentContext;
vc.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentViewController:vc animated:YES completion:NULL];

注意:我建议添加低alpha背景色让用户知道他们可以'当你将它弹出顶部时,它会与视图的其余部分进行交互...

Note: I'd recommend adding a low alpha background color to let the user know that they can't interact with the rest of the view when you pop this over top...

这篇关于带有Transition的UIModalPresentationCurrentContext?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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