【swift】显示与隐藏tabBar

颜光临
2023-12-01
  /// 是否隐藏tabbar
    ///
    /// - Parameter hiden: 是否隐藏
    func hiddenTabar(hidden : Bool,con:UIViewController){
        for subview in con.tabBarController!.view.subviews {
            if(subview.isKind(of: UITabBar.self)){
                if(hidden){
                    subview.backgroundColor = UIColor.red
                    subview.frame = CGRect(x: subview.frame.origin.x, y: UIScreen.main.bounds.size.height, width: subview.frame.size.width, height: subview.frame.size.height)
                    con.view.frame.size.height = UIConfigure.Height - 64
                }else{
                    subview.backgroundColor = UIColor.brown
                    subview.frame = CGRect(x: subview.frame.origin.x, y: UIScreen.main.bounds.size.height - 49, width: subview.frame.size.width, height: subview.frame.size.height)
                    con.view.frame.size.height = UIConfigure.Height - 64 - 49
                }
            }
        }
    }
 类似资料: