导航栏子视图未发送回

时间:2020-04-11 16:52:38

标签: ios swift xcode

我将自定义UIVisualEffectView添加到整个导航栏,并将其设置为背景。我将子视图插入0并将其发送到后面,但是导航标题和项目仍在视图后面。

我要添加图片以供参考,但这只是白色的模糊背景,您可以隐约看到其标题。

func setupNav() {
    guard let navController = navigationController else { return }
    navController.tabBarItem = UITabBarItem(title: "", image: image.withRenderingMode(.alwaysTemplate), tag: tag)
    navController.navigationBar.prefersLargeTitles = true
    navController.navigationBar.barTintColor = .none
    navController.navigationBar.isTranslucent = true
    navController.navigationBar.shadowImage = UIImage()
    navController.navigationBar.setBackgroundImage(UIImage(), for: .default)
    navController.navigationBar.topItem?.title = "Browse"
    navController.navigationBar.titleTextAttributes = [.font: UIFont.customHeaderFont(size: 23), .foregroundColor: UIColor.textColor()]
    navController.navigationBar.largeTitleTextAttributes = [.font: UIFont.customHeaderFont(size: 30), .foregroundColor: UIColor.textColor()]
    navController.navigationItem.hidesSearchBarWhenScrolling = false

    let blurView = UIVisualEffectView(effect: UIBlurEffect(style: .extraLight))
    navigationBar.insertSubview(blurView, at: 0)
    navigationBar.sendSubviewToBack(blurView)
    blurView.anchor(top: navigationBar.topAnchor, left: navigationBar.leftAnchor, bottom: navigationBar.bottomAnchor, right: navigationBar.rightAnchor, paddingTop: -60, paddingLeft: 0, paddingBottom: 0, paddingRight: 0, width: 0, height: 0)

}

0 个答案:

没有答案