swift 全局隐藏底部状态栏

2021-09-18  本文已影响0人  孤城一抹霞

方式一: 使用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
    }
}

上一篇下一篇

猜你喜欢

热点阅读