0
我试图在弹出视图的顶部放置一个UIView
- popupView,弹出视图的另一个UIView
(opaqueView),但在其他任何地方。 PopUpView与Outlet连接。把子视图放在一切之上,但在另一个UIView之下
func display() {
popupView.center = CGPointMake(CGRectGetMidX(self.view.bounds), tableView.center.y);
self.view.addSubview(popupView)
popupView.clipsToBounds = true
let opaqueView = UIView()
let screenSize: CGRect = UIScreen.mainScreen().bounds
opaqueView.frame.size = CGSize(width: screenSize.width, height: screenSize.height)
opaqueView.alpha = 0.6
UIApplication.sharedApplication().keyWindow!.insertSubview(opaqueView, belowSubview: popupView)
}
使用这种方法导致opaqueView被放置在包括popupView在内的所有东西上。相反,我希望有popupView上述opaqueView但保持opaqueView高于一切只(视图,TabBar,所以的NavBar)
为什么你将'popupView'添加到'self.view',而将'opaqueView'添加到'keyWindow'? – kennytm
因为,如果我不在'keyWindow'中添加'opaqueView','opaqueView'没有得到TabBar和NavigationBar。 – senty
为什么不将popupView添加到keyWindow呢? – kennytm