BaseTabBarController里面:
func setupVC(vc:BaseViewController,title:String? = nil){
arrayShowVc.append(vc)
let nav = BaseNavigationViewController(rootViewController: vc)
nav.setNavigationBarHidden(true, animated: true)
if isPad(),#available(iOS 18.0, *),let title = title {
//圖片用于 self.mode = .tabSidebar 時對應(yīng)的展示
let tab = UITab.init(title: title, image: UIImage(named: title + "_選中"), identifier: vc.className) { tab in
return nav
}
tabs.append(tab)
} else {
addChild(nav)
}
}
BaseViewController里面:
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.setNavigationBarHidden(true, animated: true)
//這兒只做了隱藏跟顯示
if isPad(),#available(iOS 18.0, *) {
if let children = navigationController?.children {
self.tabBarController?.setTabBarHidden(children.count > 1, animated: true)
} else{
self.tabBarController?.setTabBarHidden(false, animated: true)
}
}
}
備注:這只是我自己的處理方法旬蟋。