为什么presentModalViewController:animated: 将背景变成黑色?
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
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.
这可能会得到你想要的:
This may get you what you want:
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 afterpresentingViewController.modalPresentationStyle = UIModalPresentationOverCurrentContext;
presentingViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
then both:
[appViews.rootViewController presentViewController:presentingViewController animated:YES completion:nil];