UIView添加到UINavigationBar和UITabBar上

 func setupNav() {
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(image: UIImage(named:"shaixuan_icon"), style: .plain, target:self,action:#selector(rightNavBtnAction))
 }

@objc func rightNavBtnAction() {
        print("价格筛选")
        let priceContainerView = UIView.init(frame: CGRect(x: 0, y: 0, width: SWSize.screenWidth, height: SWSize.screenHeight))
        // 关键代码
        self.tabBarController?.view.addSubview(priceContainerView)
        priceContainerView.backgroundColor = UIColor.init(white: 0, alpha: 0.3)
    }

你可能感兴趣的:(UIView添加到UINavigationBar和UITabBar上)