我在TabBarController中有一个ViewController,我想在该ViewController中添加一个BlurView,这也会影响TabBarController,如何做到这一点。
如果我使用以下代码:
func presentBlurView() {
blurEffect = UIBlurEffect(style: blurEffectStyle)
blurView1 = UIView()
blurView1!.frame = self.view.frame
blurView1!.backgroundColor = UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.5)
self.view.addSubview(blurView1!)
blurView1!.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activateConstraints([
blurView1!.leftAnchor.constraintEqualToAnchor(self.view.leftAnchor, constant: 0),
blurView1!.topAnchor.constraintEqualToAnchor(self.view.topAnchor, constant: 0),
blurView1!.rightAnchor.constraintEqualToAnchor(self.view.rightAnchor,constant:0),
blurView1!.bottomAnchor.constraintEqualToAnchor(self.view.bottomAnchor,constant:0)
])
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: "dismissProjectDetailViewRightSight:")
tapGestureRecognizer.cancelsTouchesInView = false
blurView1!.addGestureRecognizer(tapGestureRecognizer)
}它只是在ViewController的整个视图中显示,对TabBarController没有影响。但如果我像这样改变:
UIApplication.sharedApplication().keyWindow?.addSubview(blurView1!)它适用于TabBarController,但在这种情况下,很难处理某些事情。有什么办法可以解决这个问题吗?任何帮助都将不胜感激。
发布于 2016-03-10 12:11:41
您可以尝试这样做:
self.tabBarController?.view.addSubview(blurView1!)https://stackoverflow.com/questions/35907209
复制相似问题