refactor: 更新 EPProgressHUD 和 YUMIMacroUitls.h 以兼容 iOS 13+

主要变更:
1. 在 EPProgressHUD.swift 中引入 keyWindow 的兼容获取方法,替换原有的 UIApplication.shared.keyWindow 调用。
2. 在 YUMIMacroUitls.h 中添加状态栏高度和 keyWindow 的兼容宏定义,确保在 iOS 13+ 中正确获取相关窗口和状态栏信息。

此更新旨在提升代码的兼容性和稳定性,确保在新版本的 iOS 中正常运行。
This commit is contained in:
edwinQQQ
2025-10-11 17:36:28 +08:00
parent 7626eb8351
commit c0441f7853
2 changed files with 49 additions and 6 deletions

View File

@@ -13,13 +13,25 @@ import Foundation
private static var currentHUD: MBProgressHUD?
/// window iOS 13+
private static var keyWindow: UIWindow? {
if #available(iOS 13.0, *) {
return UIApplication.shared.connectedScenes
.compactMap { $0 as? UIWindowScene }
.flatMap { $0.windows }
.first { $0.isKeyWindow }
} else {
return UIApplication.shared.keyWindow
}
}
///
/// - Parameters:
/// - uploaded:
/// - total:
@objc static func showProgress(_ uploaded: Int, total: Int) {
DispatchQueue.main.async {
guard let window = UIApplication.shared.keyWindow else { return }
guard let window = keyWindow else { return }
if let hud = currentHUD {
// HUD
@@ -40,8 +52,7 @@ import Foundation
/// HUD
@objc static func dismiss() {
DispatchQueue.main.async {
guard let window = UIApplication.shared.keyWindow,
let hud = currentHUD else { return }
guard let hud = currentHUD else { return }
hud.hide(animated: true)
currentHUD = nil