From ac84f81ca2311300b431c1bfb9f71253b59073f2 Mon Sep 17 00:00:00 2001 From: 杨锴 <841720330@qq.com> Date: 星期三, 04 六月 2025 00:16:22 +0800 Subject: [PATCH] 修改部分 --- DolphinEnglishLearnStudent/Base/BaseVC.swift | 174 +++++++++++++++++++++++++++++----------------------------- 1 files changed, 87 insertions(+), 87 deletions(-) diff --git a/DolphinEnglishLearnStudent/Base/BaseVC.swift b/DolphinEnglishLearnStudent/Base/BaseVC.swift index a87805d..0f9d8dc 100644 --- a/DolphinEnglishLearnStudent/Base/BaseVC.swift +++ b/DolphinEnglishLearnStudent/Base/BaseVC.swift @@ -14,113 +14,113 @@ class BaseVC: UIViewController { - var disposeBag:DisposeBag! - let refreshStatus = BehaviorSubject(value: RefreshStatus.others) + var disposeBag:DisposeBag! + let refreshStatus = BehaviorSubject(value: RefreshStatus.others) - var yy_popBlock:(() -> Void)? - open var nav_back_img:UIImage = UIImage.init(named: "btn_back") ?? UIImage.init() { - didSet { - let btn = navigationItem.leftBarButtonItem?.customView as! UIButton - btn.setImage(nav_back_img, for: .normal) - } - } + var yy_popBlock:(() -> Void)? + open var nav_back_img:UIImage = UIImage.init(named: "btn_back") ?? UIImage.init() { + didSet { + let btn = navigationItem.leftBarButtonItem?.customView as! UIButton + btn.setImage(nav_back_img, for: .normal) + } + } - override func viewWillAppear(_ animated: Bool) { - super.viewWillAppear(animated) - navigationController?.delegate?.navigationController?(navigationController!, willShow: self, animated: true) - } + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + navigationController?.delegate?.navigationController?(navigationController!, willShow: self, animated: true) + } - override func viewDidLoad() { - super.viewDidLoad() + override func viewDidLoad() { + super.viewDidLoad() - disposeBag = DisposeBag() - setUI() - setRx() - setData() + disposeBag = DisposeBag() + setUI() + setRx() + setData() - if navigationController?.viewControllers.count ?? 0 > 1{ - let backButton = QMUIButton(type: .custom) - backButton.setImage(UIImage(named: "btn_back"), for: .normal) - backButton.setTitle(self.title, for: .normal) - backButton.setTitleColor(.black.withAlphaComponent(0.81), for: .normal) - backButton.titleLabel?.font = UIFont.systemFont(ofSize: 18, weight: .medium) - backButton.imagePosition = .left - backButton.spacingBetweenImageAndTitle = 35 - backButton.addTarget(self, action: #selector(backItemEvent), for: .touchUpInside) - navigationItem.leftBarButtonItem = UIBarButtonItem(customView: backButton) - } + if navigationController?.viewControllers.count ?? 0 > 1{ + let backButton = QMUIButton(type: .custom) + backButton.setImage(UIImage(named: "btn_back"), for: .normal) + backButton.setTitle(self.title, for: .normal) + backButton.setTitleColor(.black.withAlphaComponent(0.81), for: .normal) + backButton.titleLabel?.font = UIFont.systemFont(ofSize: 18, weight: .medium) + backButton.imagePosition = .left + backButton.spacingBetweenImageAndTitle = 35 + backButton.addTarget(self, action: #selector(backItemEvent), for: .touchUpInside) + navigationItem.leftBarButtonItem = UIBarButtonItem(customView: backButton) + } - if !self.isKind(of: HomeVC.self) && !self.isKind(of: HomeListenSubVC.self) && !self.isKind(of: HomeListenFight_lesson_1_VC.self) && !self.isKind(of: HomeListenFight_lesson_2_VC.self) && !self.isKind(of: HomeListenFight_lesson_3_VC.self) && !self.isKind(of: HomeListenFight_lesson_4_VC.self) && !self.isKind(of: HomeListenFight_lesson_5_VC.self) && !self.isKind(of: HomeListenGame_1_VC.self) && !self.isKind(of: HomeListenGame_2_VC.self) && !self.isKind(of: HomeListenStory_1_VC.self) && !self.isKind(of: HomeListenStory_2_VC.self) && !self.isKind(of: LoginVC.self){ - let titleV = UIView() -// titleV.bounds = CGRect(x: 0, y: 0, width: 156, height: 24) - titleV.sizeToFit() - let imgV = UIImageView(image: UIImage(named: "bg_logo")) - imgV.contentMode = .scaleAspectFit - titleV.addSubview(imgV) - imgV.snp.makeConstraints { make in - make.edges.equalToSuperview() - } + if !self.isKind(of: HomeVC.self) && !self.isKind(of: HomeListenSubVC.self) && !self.isKind(of: HomeListenFight_lesson_1_VC.self) && !self.isKind(of: HomeListenFight_lesson_2_VC.self) && !self.isKind(of: HomeListenFight_lesson_3_VC.self) && !self.isKind(of: HomeListenFight_lesson_4_VC.self) && !self.isKind(of: HomeListenFight_lesson_5_VC.self) && !self.isKind(of: HomeListenGame_1_VC.self) && !self.isKind(of: HomeListenGame_2_VC.self) && !self.isKind(of: HomeListenStory_1_VC.self) && !self.isKind(of: HomeListenStory_2_VC.self) && !self.isKind(of: LoginVC.self){ + let titleV = UIView() + // titleV.bounds = CGRect(x: 0, y: 0, width: 156, height: 24) + titleV.sizeToFit() + let imgV = UIImageView(image: UIImage(named: "bg_logo")) + imgV.contentMode = .scaleAspectFit + titleV.addSubview(imgV) + imgV.snp.makeConstraints { make in + make.edges.equalToSuperview() + } - view.addSubview(titleV) - titleV.snp.makeConstraints { make in - make.center.equalToSuperview() - } + view.addSubview(titleV) + titleV.snp.makeConstraints { make in + make.center.equalToSuperview() + } - navigationItem.titleView = titleV - } - } + navigationItem.titleView = titleV + } + } - func setRx(){ - } + func setRx(){ + } - func setUI(){ - view.backgroundColor = Config.ThemeBGColor + func setUI(){ + view.backgroundColor = Config.ThemeBGColor - } + } - func setData(){ + func setData(){ - } + } - func refreshUI(){} + func refreshUI(){} - func push(vc:UIViewController){ - vc.hidesBottomBarWhenPushed = true - navigationController?.pushViewController(vc, animated: true) - } + func push(vc:UIViewController){ + vc.hidesBottomBarWhenPushed = true + navigationController?.pushViewController(vc, animated: true) + } - override var preferredStatusBarStyle: UIStatusBarStyle{ - return .lightContent - } + override var preferredStatusBarStyle: UIStatusBarStyle{ + return .lightContent + } - @objc fileprivate func backItemEvent() { - // 拦截pop事件 - if (yy_popBlock != nil) { - yy_popBlock?() - return - } - navigationController?.popViewController(animated: true) - } + @objc fileprivate func backItemEvent() { + // 拦截pop事件 + if (yy_popBlock != nil) { + yy_popBlock?() + return + } + navigationController?.popViewController(animated: true) + } - override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { - coordinator.animate(alongsideTransition: { [weak self] (context) in - let orient = UIApplication.shared.statusBarOrientation - switch orient { - case .landscapeLeft, .landscapeRight: - //横屏时禁止左拽滑出 - self?.navigationController?.interactivePopGestureRecognizer?.isEnabled = false - default: - //竖屏时允许左拽滑出 - self?.navigationController?.interactivePopGestureRecognizer?.isEnabled = true - } - }) - super.viewWillTransition(to: size, with: coordinator) - } + override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { + coordinator.animate(alongsideTransition: { [weak self] (context) in + let orient = UIApplication.shared.statusBarOrientation + switch orient { + case .landscapeLeft, .landscapeRight: + //横屏时禁止左拽滑出 + self?.navigationController?.interactivePopGestureRecognizer?.isEnabled = false + default: + //竖屏时允许左拽滑出 + self?.navigationController?.interactivePopGestureRecognizer?.isEnabled = true + } + }) + super.viewWillTransition(to: size, with: coordinator) + } - deinit { - LogInfo(String(format: "%@ 已释放", NSStringFromClass(self.classForCoder).components(separatedBy: ".").last!)) - } + deinit { + LogInfo(String(format: "%@ 已释放", NSStringFromClass(self.classForCoder).components(separatedBy: ".").last!)) + } } -- Gitblit v1.7.1