swift:导航栏模糊效果

时间:2017-08-26 10:10:15

标签: ios swift uinavigationbar

我使用此代码模糊导航栏:

let visualEffectView   = UIVisualEffectView(effect: UIBlurEffect(style: .light))
visualEffectView.frame =  (self.navigationController?.navigationBar.bounds.insetBy(dx: 0, dy: -10).offsetBy(dx: 0, dy: -10))!
self.navigationController?.navigationBar.isTranslucent = true
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
self.navigationController?.navigationBar.addSubview(visualEffectView)
self.navigationController?.navigationBar.sendSubview(toBack: visualEffectView)

但是我的后退按钮不起作用,并且没有出现其他按钮。如何解决?

1 个答案:

答案 0 :(得分:2)

只是你应该禁用" isUserInteractionEnabled"到你的visualEffectView

添加以下行:

 visualEffectView.layer.zPosition = -1;
    visualEffectView.isUserInteractionEnabled = false