方式一: 使用UINavigationControllerDelegate
import UIKit
extension UINavigationController: UINavigationControllerDelegate {
open override func awakeFromNib() {
super.awakeFromNib()
delegate = self
}
public func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) {
setTabbarHidden(isHidden: viewControllers.count != 1, vc: viewController)
}
public func setTabbarHidden(isHidden: Bool, vc: UIViewController) {
guard let tabBar = self.tabBarController?.tabBar else {
return
}
tabBar.isHidden = isHidden
}
}
网友评论