1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- //
- // YMNavigationController.swift
- // MvpGoods
- //
- // Created by 小花 on 2019/3/18.
- // Copyright © 2019年 MVP. All rights reserved.
- //
- import UIKit
- class YMNavigationController: UINavigationController {
-
-
- override func viewDidLoad() {
- super.viewDidLoad()
-
- }
-
- /**
- # 统一所有控制器导航栏左上角的返回按钮
- # 让所有push进来的控制器,它的导航栏左上角的内容都一样
- # 能拦截所有的push操作
- - parameter viewController: 需要压栈的控制器
- - parameter animated: 是否动画
- */
-
- override func pushViewController(_ viewController: UIViewController, animated: Bool) {
- /// 这时push进来的控制器viewController,不是第一个子控制器(不是根控制器)
- if viewControllers.count > 0 {
- // push 后隐藏 tabbar
- viewController.hidesBottomBarWhenPushed = true
- viewController.navigationItem.leftBarButtonItem = UIBarButtonItem(image: UIImage(named: "back_white"), style: .plain, target: self, action: #selector(navigationBackClick))
- }
- super.pushViewController(viewController, animated: true)
- }
- /// 返回按钮
- @objc func navigationBackClick() {
-
- if UIApplication.shared.isNetworkActivityIndicatorVisible {
- UIApplication.shared.isNetworkActivityIndicatorVisible = false
- }
- popViewController(animated: true)
- }
- }
|