优惠券swift版马甲包

YMNavigationController.swift 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //
  2. // YMNavigationController.swift
  3. // MvpGoods
  4. //
  5. // Created by 小花 on 2019/3/18.
  6. // Copyright © 2019年 MVP. All rights reserved.
  7. //
  8. import UIKit
  9. class YMNavigationController: UINavigationController {
  10. override func viewDidLoad() {
  11. super.viewDidLoad()
  12. }
  13. /**
  14. # 统一所有控制器导航栏左上角的返回按钮
  15. # 让所有push进来的控制器,它的导航栏左上角的内容都一样
  16. # 能拦截所有的push操作
  17. - parameter viewController: 需要压栈的控制器
  18. - parameter animated: 是否动画
  19. */
  20. override func pushViewController(_ viewController: UIViewController, animated: Bool) {
  21. /// 这时push进来的控制器viewController,不是第一个子控制器(不是根控制器)
  22. if viewControllers.count > 0 {
  23. // push 后隐藏 tabbar
  24. viewController.hidesBottomBarWhenPushed = true
  25. viewController.navigationItem.leftBarButtonItem = UIBarButtonItem(image: UIImage(named: "back_white"), style: .plain, target: self, action: #selector(navigationBackClick))
  26. }
  27. super.pushViewController(viewController, animated: true)
  28. }
  29. /// 返回按钮
  30. @objc func navigationBackClick() {
  31. if UIApplication.shared.isNetworkActivityIndicatorVisible {
  32. UIApplication.shared.isNetworkActivityIndicatorVisible = false
  33. }
  34. popViewController(animated: true)
  35. }
  36. }