为什么presentModalViewController:animated: 将背景变成黑色?

发布于 2024-12-02 13:09:11 字数 337 浏览 0 评论 0原文

我正在使用 presentModalViewController:animated: ,虽然在功能上它在视觉上工作正常,但它有一个我想删除的工件。当模态呈现的 viewController 出现时,其父 viewController 完全隐藏,背景变成黑色。这不是我想要的。我的子 viewController 的视图是半透明的,我想显示它后面的父 viewControllers 视图。我想要的效果是一张描图纸在背景上滑动。

我假设 presentModalViewController:animated: 支持这一点。难道不是这样吗?

谢谢,
道格

I am using presentModalViewController:animated: and while functionally it works correctly visually it has an artifact I want to remove. When the modally presented viewController appears its parent viewController is completely hidden with the background turning black. This is not what I want. My child viewController's view is translucent and I want to reveal the parent viewControllers view behind it. The effect I want is a piece of tracing paper sliding over the background.

I assumed presentModalViewController:animated: supported this. Is that not the case?

Thanks,
Doug

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

も让我眼熟你 2024-12-09 13:09:11

NavigationController视图控制器 的设计方式是一次只能显示一个视图控制器。当新的视图控制器被推送/呈现时,先前的视图控制器将被系统隐藏。因此,当您减少模态视图的 alpha 时,您可能会看到窗口的背景颜色(您现在看到的黑色)。

如果您希望半透明视图滑入主视图,您可以将该视图添加为主视图的子视图,并使用 UIView 动画为其设置动画。

NavigationController and the View Controllers are designed in such a way that only one view controller may show at a time. When a new view controller is pushed/presented the previous view controller will be hidden by the system. So when you reduce the modal view's alpha you will possibly see the window's backgroundColor (the black color you see now).

If you want a translucent view to slide-in over the main view, you can add the view as the subView of main view and animate it using UIView Animations.

深海不蓝 2024-12-09 13:09:11

这可能会得到你想要的:

presentingViewController.modalPresentationStyle = UIModalPresentationCurrentContext;

This may get you what you want:

presentingViewController.modalPresentationStyle = UIModalPresentationCurrentContext;
君勿笑 2024-12-09 13:09:11

PresentingViewController.modalPresentationStyle = UIModalPresentationCurrentContext;
在 ios7 之后不起作用,可以通过

presentingViewController.modalPresentationStyle = UIModalPresentationOverCurrentContext;
之后修复它
presentingViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;

然后两者:
[appViews.rootViewControllerpresentViewController:presentingViewController动画:YES完成:nil];

presentingViewController.modalPresentationStyle = UIModalPresentationCurrentContext;
doesn't work after ios7,you can fix it by after

presentingViewController.modalPresentationStyle = UIModalPresentationOverCurrentContext;
presentingViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;

then both:
[appViews.rootViewController presentViewController:presentingViewController animated:YES completion:nil];

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文