美文网首页
swift 全局隐藏底部状态栏

swift 全局隐藏底部状态栏

作者: 孤城一抹霞 | 来源:发表于2021-09-18 09:06 被阅读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
        }
    }
    
    

    相关文章

      网友评论

          本文标题:swift 全局隐藏底部状态栏

          本文链接:https://www.haomeiwen.com/subject/pvzjgltx.html