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 时对应的展示
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)
}
}
}
备注:这只是我自己的处理方法。