如何更改UIPopoverPresentationController之后的叠加层的不透明度? [英] How can I change the opacity of the overlay behind UIPopoverPresentationController?
问题描述
我正在使用UIPopoverPresentationController
在iOS应用中显示弹出窗口.我想使弹出式窗口后面的背景变暗.我怎样才能做到这一点?
I'm using UIPopoverPresentationController
to present popovers in an iOS app. I want to dim the background behind the popover when it comes up. How can I do this? Is there an API for it somewhere, or am I going to have to overlay something on the main view when I present the popover?
推荐答案
当我展示弹出窗口时,我最终通过将自己的叠加层覆盖在主视图上来解决了这个问题.我之所以能够轻松做到这一点,是因为我通过一个单例协调器类来处理所有弹出窗口,我的根视图控制器不是导航控制器,并且我可以在任何地方轻松实现它.我还必须在弹出窗口中出现的任何地方都创建UINavigationController
的子类,以便可以覆盖dismissViewControllerAnimated:completion:
并通知协调器,以便删除覆盖(通过编程方式关闭弹出窗口时,didDismiss委托方法不会被调用).
I ended up solving this by putting my own overlay over my main view when I present the popover. I was able to do this easily because I do all my popovers through one singleton coordinator class, my root view controller isn't a navigation controller, and I can get to it easily everywhere. I also had to create a subclass of UINavigationController
everywhere I presented one in a popover so I could override dismissViewControllerAnimated:completion:
and notify the coordinator so it removed the overlay (the didDismiss delegate method doesn't get called when the popover is dismissed programmatically).
这篇关于如何更改UIPopoverPresentationController之后的叠加层的不透明度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!