我试图在另一个之上设置一个视图控制器,同时保持第一个视图控制器的可见性。
但是,我看不到第一个,因为我有一个UITransitionView,上面有一个UIView (第一个在层次结构中,这就是我知道.OverCurrentContext正在工作的原因)
这应该是一个非常简单的代码,我不知道发生了什么。我知道我不能碰UITransitionView,这就是为什么我不知道该怎么做。
let vc = storyBoard.instantiateInitialViewController() as MyPresenterViewController
vc.view.backgroundColor = .clearColor()
vc.modalPresentationStyle = .OverCurrentContext
viewControllerToPresentIn.presentViewController(vc, animated: true, completion: nil)如有建议,将不胜感激。
诚挚的问候,
发布于 2017-05-15 07:11:09
这个反应有点晚了,但我最近遇到了一个类似的问题。我想要呈现的一种模式(带有半透明的面纱)被一个白色的UITransitionView所包含,隐藏着潜在的视图。我怀疑在某些情况下,当您发出一个TransitionView调用以显示您的模式时,会注入此controller.present() (但不知道原因或时间)。
作为一个快速和肮脏的解决方法,您可以尝试在出现之前清除您的模式的父视图的背景。由于某些原因,UITransitionView也会得到一个清晰的颜色,一旦你呈现你的模式。
extension UIView {
//This will eventually get to the UITransitionView and clear the background.
func clearHierarchyBackground() {
self.backgroundColor = .clear
if let superView = self.superview {
superview.clearHierarchyBackground()
}
}
}
let parentController = MyParentViewController()
let childController = MyModalViewController()
childController.modalPresentationStyle = .overFullScreen //.overCurrentContext should also work..
childController.view.clearHierarchyBackground()
/* The above makes your controller root view .clear
so you need to add subviews with transparency &
content as you see fit.*/
parentController.present(childController, animated:true....)https://stackoverflow.com/questions/30113897
复制相似问题