diff --git a/Example-Old/Example/Assets.xcassets/prohud.rainbow.circle.imageset/Contents.json b/Example-Old/Example/Assets.xcassets/prohud.rainbow.circle.imageset/Contents.json new file mode 100644 index 0000000..266990e --- /dev/null +++ b/Example-Old/Example/Assets.xcassets/prohud.rainbow.circle.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "prohud.rainbow.circle@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "prohud.rainbow.circle@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Example-Old/Example/Assets.xcassets/prohud.rainbow.circle.imageset/prohud.rainbow.circle@2x.png b/Example-Old/Example/Assets.xcassets/prohud.rainbow.circle.imageset/prohud.rainbow.circle@2x.png new file mode 100644 index 0000000..51fdd40 Binary files /dev/null and b/Example-Old/Example/Assets.xcassets/prohud.rainbow.circle.imageset/prohud.rainbow.circle@2x.png differ diff --git a/Example-Old/Example/Assets.xcassets/prohud.rainbow.circle.imageset/prohud.rainbow.circle@3x.png b/Example-Old/Example/Assets.xcassets/prohud.rainbow.circle.imageset/prohud.rainbow.circle@3x.png new file mode 100644 index 0000000..d6d457b Binary files /dev/null and b/Example-Old/Example/Assets.xcassets/prohud.rainbow.circle.imageset/prohud.rainbow.circle@3x.png differ diff --git a/Example-Old/Example/Assets.xcassets/prohud.trash.imageset/Contents.json b/Example-Old/Example/Assets.xcassets/prohud.trash.imageset/Contents.json new file mode 100644 index 0000000..551989a --- /dev/null +++ b/Example-Old/Example/Assets.xcassets/prohud.trash.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "prohud.trash@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "prohud.trash@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Example-Old/Example/Assets.xcassets/prohud.trash.imageset/prohud.trash@2x.png b/Example-Old/Example/Assets.xcassets/prohud.trash.imageset/prohud.trash@2x.png new file mode 100644 index 0000000..25fb085 Binary files /dev/null and b/Example-Old/Example/Assets.xcassets/prohud.trash.imageset/prohud.trash@2x.png differ diff --git a/Example-Old/Example/Assets.xcassets/prohud.trash.imageset/prohud.trash@3x.png b/Example-Old/Example/Assets.xcassets/prohud.trash.imageset/prohud.trash@3x.png new file mode 100644 index 0000000..1411e5e Binary files /dev/null and b/Example-Old/Example/Assets.xcassets/prohud.trash.imageset/prohud.trash@3x.png differ diff --git a/Example-Old/Example/BaseListVC.swift b/Example-Old/Example/BaseListVC.swift index 2cee674..604aa2c 100644 --- a/Example-Old/Example/BaseListVC.swift +++ b/Example-Old/Example/BaseListVC.swift @@ -43,8 +43,13 @@ class BaseListVC: UIViewController { var secs = [Section]() lazy var tableView: UITableView = { - let tv = UITableView(frame: .zero, style: .insetGrouped) - + let tv: UITableView + if #available(iOS 13.0, *) { + tv = UITableView(frame: .zero, style: .insetGrouped) + } else { + // Fallback on earlier versions + tv = UITableView(frame: .zero, style: .grouped) + } return tv }() diff --git a/Example-Old/Example/TestGuardVC.swift b/Example-Old/Example/TestGuardVC.swift index 49d951c..dc0cc36 100644 --- a/Example-Old/Example/TestGuardVC.swift +++ b/Example-Old/Example/TestGuardVC.swift @@ -35,6 +35,11 @@ class TestGuardVC: BaseListVC { vm.add(action: .cancel, title: "取消", handler: nil) } } + DispatchQueue.main.asyncAfter(deadline: .now()+1) { + Guard.find("del") { vc in + vc.pop() + } + } } // MARK: 升级至专业版 diff --git a/Example-Old/Podfile.lock b/Example-Old/Podfile.lock index daef591..a973bee 100644 --- a/Example-Old/Podfile.lock +++ b/Example-Old/Podfile.lock @@ -1,5 +1,5 @@ PODS: - - Inspire (2.0.0) + - Inspire (2.1.0) - ProHUD (1.0): - Inspire - SnapKit (= 5.0) @@ -21,10 +21,10 @@ EXTERNAL SOURCES: :path: ".." SPEC CHECKSUMS: - Inspire: 7556357c9c90d5e886f3be5d29fe1e0222b694e1 + Inspire: 087dce1e4ff902d26d79bd3453352af09411c172 ProHUD: 7128b55036885ac4f8b4d0b0783ee6f8eb3a2ea9 SnapKit: fd22d10eb9aff484d79a8724eab922c1ddf89bcf PODFILE CHECKSUM: 80148eec6ba2e9631b208c7b277316b6c551afc4 -COCOAPODS: 1.9.2 +COCOAPODS: 1.10.1 diff --git a/Example-Old/README.md b/Example-Old/README.md new file mode 100644 index 0000000..67a6bd1 --- /dev/null +++ b/Example-Old/README.md @@ -0,0 +1,4 @@ +# 使用 AppDelegate 的项目 + + + diff --git a/Example-Xcode11/Example-Xcode11/SceneDelegate.swift b/Example-Xcode11/Example-Xcode11/SceneDelegate.swift index 20e1001..a170a6c 100644 --- a/Example-Xcode11/Example-Xcode11/SceneDelegate.swift +++ b/Example-Xcode11/Example-Xcode11/SceneDelegate.swift @@ -19,7 +19,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). guard let scene = (scene as? UIWindowScene) else { return } - + print(scene.statusBarManager?.statusBarFrame) let rootVC = RootVC() window?.rootViewController = rootVC window?.makeKeyAndVisible() diff --git a/Example-Xcode11/README.md b/Example-Xcode11/README.md new file mode 100644 index 0000000..018d4d4 --- /dev/null +++ b/Example-Xcode11/README.md @@ -0,0 +1,2 @@ +# 使用 SceneDelegate 的项目 + diff --git a/Package.swift b/Package.swift index 6d19920..4e71d83 100644 --- a/Package.swift +++ b/Package.swift @@ -10,7 +10,7 @@ let package = Package( ], dependencies: [ .package(url: "https://github.com/SnapKit/SnapKit.git", "5.0.0" ..< "6.0.0"), - .package(url: "https://github.com/xaoxuu/Inspire.git", "2.0.0" ..< "3.0.0"), + .package(url: "https://github.com/xaoxuu/Inspire.git", "2.1.0" ..< "3.0.0"), ], targets: [ .target( diff --git a/ProHUD.xcodeproj/project.pbxproj b/ProHUD.xcodeproj/project.pbxproj index 445bfa6..676381f 100644 --- a/ProHUD.xcodeproj/project.pbxproj +++ b/ProHUD.xcodeproj/project.pbxproj @@ -23,8 +23,8 @@ CDB6A07B22EEF06500AF6CF0 /* HUDController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDB6A07A22EEF06500AF6CF0 /* HUDController.swift */; }; CDB6A07D22EEF19D00AF6CF0 /* HUDConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDB6A07C22EEF19D00AF6CF0 /* HUDConfig.swift */; }; CDC39CFD22FD6DDF0070E914 /* GuardModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDC39CFC22FD6DDF0070E914 /* GuardModel.swift */; }; - CDC67BE92490A19100CC6FE6 /* BuildFile in Frameworks */ = {isa = PBXBuildFile; productRef = CDC67BE82490A19100CC6FE6 /* SwiftPackageProductDependency */; }; - CDC67BEC2490A1D100CC6FE6 /* BuildFile in Frameworks */ = {isa = PBXBuildFile; productRef = CDC67BEB2490A1D100CC6FE6 /* SwiftPackageProductDependency */; }; + CDC67BE92490A19100CC6FE6 /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = CDC67BE82490A19100CC6FE6 /* SnapKit */; }; + CDC67BEC2490A1D100CC6FE6 /* Inspire in Frameworks */ = {isa = PBXBuildFile; productRef = CDC67BEB2490A1D100CC6FE6 /* Inspire */; }; CDF2C58924A0572C002ECDD5 /* HUDUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDF2C58824A0572C002ECDD5 /* HUDUtils.swift */; }; /* End PBXBuildFile section */ @@ -58,8 +58,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - CDC67BEC2490A1D100CC6FE6 /* BuildFile in Frameworks */, - CDC67BE92490A19100CC6FE6 /* BuildFile in Frameworks */, + CDC67BEC2490A1D100CC6FE6 /* Inspire in Frameworks */, + CDC67BE92490A19100CC6FE6 /* SnapKit in Frameworks */, 36CB9DEED3C3E823FE7B1C75 /* Pods_ProHUD.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -189,8 +189,8 @@ ); name = ProHUD; packageProductDependencies = ( - CDC67BE82490A19100CC6FE6 /* SwiftPackageProductDependency */, - CDC67BEB2490A1D100CC6FE6 /* SwiftPackageProductDependency */, + CDC67BE82490A19100CC6FE6 /* SnapKit */, + CDC67BEB2490A1D100CC6FE6 /* Inspire */, ); productName = ProHUD; productReference = CD95D21C22E72C4C007559A3 /* ProHUD.framework */; @@ -221,8 +221,8 @@ ); mainGroup = CD95D21222E72C4C007559A3; packageReferences = ( - CDC67BE72490A19100CC6FE6 /* RemoteSwiftPackageReference */, - CDC67BEA2490A1D100CC6FE6 /* RemoteSwiftPackageReference */, + CDC67BE72490A19100CC6FE6 /* XCRemoteSwiftPackageReference "SnapKit" */, + CDC67BEA2490A1D100CC6FE6 /* XCRemoteSwiftPackageReference "Inspire" */, ); productRefGroup = CD95D21D22E72C4C007559A3 /* Products */; projectDirPath = ""; @@ -493,7 +493,7 @@ /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ - CDC67BE72490A19100CC6FE6 /* RemoteSwiftPackageReference */ = { + CDC67BE72490A19100CC6FE6 /* XCRemoteSwiftPackageReference "SnapKit" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/SnapKit/SnapKit"; requirement = { @@ -501,25 +501,25 @@ minimumVersion = 5.0.1; }; }; - CDC67BEA2490A1D100CC6FE6 /* RemoteSwiftPackageReference */ = { + CDC67BEA2490A1D100CC6FE6 /* XCRemoteSwiftPackageReference "Inspire" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/xaoxuu/Inspire"; requirement = { kind = upToNextMajorVersion; - minimumVersion = 2.0.0; + minimumVersion = 2.1.0; }; }; /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ - CDC67BE82490A19100CC6FE6 /* SwiftPackageProductDependency */ = { + CDC67BE82490A19100CC6FE6 /* SnapKit */ = { isa = XCSwiftPackageProductDependency; - package = CDC67BE72490A19100CC6FE6 /* RemoteSwiftPackageReference */; + package = CDC67BE72490A19100CC6FE6 /* XCRemoteSwiftPackageReference "SnapKit" */; productName = SnapKit; }; - CDC67BEB2490A1D100CC6FE6 /* SwiftPackageProductDependency */ = { + CDC67BEB2490A1D100CC6FE6 /* Inspire */ = { isa = XCSwiftPackageProductDependency; - package = CDC67BEA2490A1D100CC6FE6 /* RemoteSwiftPackageReference */; + package = CDC67BEA2490A1D100CC6FE6 /* XCRemoteSwiftPackageReference "Inspire" */; productName = Inspire; }; /* End XCSwiftPackageProductDependency section */ diff --git a/Source/Alert/AlertConfig.swift b/Source/Alert/AlertConfig.swift index 487f187..8874f4a 100644 --- a/Source/Alert/AlertConfig.swift +++ b/Source/Alert/AlertConfig.swift @@ -10,7 +10,7 @@ import UIKit import SnapKit public extension UIWindow.Level { - static let proAlert = UIWindow.Level.alert - 1 + static let alertForProHUD = UIWindow.Level.alert - 1 } public extension ProHUD.Configuration { @@ -75,7 +75,7 @@ public extension ProHUD.Configuration { // MARK: - 内部调用 -internal extension ProHUD.Configuration.Alert { +extension ProHUD.Configuration.Alert { var reloadData: (ProHUD.Alert) -> Void { return privReloadData diff --git a/Source/Alert/AlertController.swift b/Source/Alert/AlertController.swift index cdd17c1..ce5cf37 100644 --- a/Source/Alert/AlertController.swift +++ b/Source/Alert/AlertController.swift @@ -14,9 +14,9 @@ public typealias Alert = ProHUD.Alert public extension ProHUD { class Alert: HUDController { - internal static var alerts = [Alert]() + static var alerts = [Alert]() - internal static var alertWindow: UIWindow? + static var alertWindow: UIWindow? /// 内容视图 public var contentView = createBlurView() @@ -96,9 +96,7 @@ public extension Alert { window.resignKey() window.addSubview(view) if #available(iOS 13.0, *) { - window.windowScene = cfg.windowScene ?? UIApplication.shared.windows.first?.windowScene - } else { - // Fallback on earlier versions + window.windowScene = cfg.windowScene ?? .currentWindowScene } view.transform = .init(scaleX: 1.2, y: 1.2) view.alpha = 0 @@ -234,7 +232,7 @@ public extension Alert { // MARK: - 创建和设置 -internal extension Alert { +extension Alert { /// 插入一个按钮 /// - Parameter style: 样式 @@ -338,19 +336,13 @@ fileprivate extension Alert { alertWindow = w w.backgroundColor = UIColor.init(red: 0, green: 0, blue: 0, alpha: 0) // 比原生alert层级低一点 - w.windowLevel = .proAlert + w.windowLevel = .alertForProHUD return w } class func privRemoveItemFromArray(alert: Alert) { if alerts.count > 1 { - for (i, a) in alerts.enumerated() { - if a == alert { - if i < alerts.count { - alerts.remove(at: i) - } - } - } + alerts.removeAll { $0 == alert } privUpdateAlertsLayout() } else if alerts.count == 1 { alerts.removeAll() diff --git a/Source/Alert/AlertModel.swift b/Source/Alert/AlertModel.swift index 39360fc..2b4ce60 100644 --- a/Source/Alert/AlertModel.swift +++ b/Source/Alert/AlertModel.swift @@ -47,15 +47,15 @@ public extension Alert { // MARK: 私有 /// 持续时间 - internal var durationBlock: DispatchWorkItem? + var durationBlock: DispatchWorkItem? /// 强制退出按钮 - internal var hideTimerBlock: DispatchWorkItem? + var hideTimerBlock: DispatchWorkItem? /// 强制退出代码 - internal var forceQuitCallback: (() -> Void)? + var forceQuitCallback: (() -> Void)? - internal func updateDuration() { + func updateDuration() { durationBlock?.cancel() if let t = duration ?? scene.alertDuration, t > 0 { durationBlock = DispatchWorkItem(block: { [weak self] in diff --git a/Source/Guard/GuardConfig.swift b/Source/Guard/GuardConfig.swift index b8566fa..6ae652f 100644 --- a/Source/Guard/GuardConfig.swift +++ b/Source/Guard/GuardConfig.swift @@ -51,7 +51,7 @@ public extension ProHUD.Configuration { // MARK: - 内部调用 -internal extension ProHUD.Configuration.Guard { +extension ProHUD.Configuration.Guard { var reloadData: (ProHUD.Guard) -> Void { return privReloadData diff --git a/Source/Guard/GuardController.swift b/Source/Guard/GuardController.swift index c9de5f3..b379656 100644 --- a/Source/Guard/GuardController.swift +++ b/Source/Guard/GuardController.swift @@ -119,21 +119,8 @@ public extension Guard { } if let vc = viewController ?? cfg.rootViewController { return f(vc) - } else { - // 尝试获取RootVC - let ws = UIApplication.shared.windows.filter { (w) -> Bool in - // 去除掉诸如 UITextEffectsWindow 这样的类,去掉隐藏的Window - if "\(type(of:w))" == "UIWindow" && w.isHidden == false && w.windowLevel == .normal { - return true - } else { - return false - } - } - for w in ws { - if let vc = w.rootViewController { - return f(vc) - } - } + } else if let vc = UIViewController.currentRootViewController { + return f(vc) debug("⚠️自动获取根控制器失败,请设置根控制器或者传入需要push到的控制器") } return self @@ -200,23 +187,15 @@ public extension Guard { /// 查找指定的实例 /// - Parameter identifier: 指定实例的标识 class func find(_ identifier: String?, from viewController: UIViewController? = nil) -> [Guard] { - var gg = [Guard]() - if let vc = viewController ?? cfg.rootViewController { - for child in vc.children { - if child.isKind(of: Guard.self) { - if let g = child as? Guard { - if let id = identifier { - if g.identifier == id { - gg.append(g) - } - } else { - gg.append(g) - } - } - } + guard let vc = viewController ?? cfg.rootViewController ?? UIViewController.currentRootViewController else { return [] } + return vc.children.compactMap { (child) -> Guard? in + guard let child = child as? Guard else { return nil } + if let id = identifier, child.identifier == id { + return child + } else { + return child } } - return gg } /// 查找指定的实例 @@ -249,7 +228,7 @@ public extension Guard { // MARK: - 创建和设置 -internal extension Guard { +extension Guard { /// 加载一个标题 /// - Parameter text: 文本 diff --git a/Source/Guard/GuardModel.swift b/Source/Guard/GuardModel.swift index b4711da..65f7cce 100644 --- a/Source/Guard/GuardModel.swift +++ b/Source/Guard/GuardModel.swift @@ -12,7 +12,7 @@ public extension Guard { struct ViewModel { - internal weak var vc: Guard? + weak var vc: Guard? } diff --git a/Source/HUDConfig.swift b/Source/HUDConfig.swift index 83fddd7..f0a3df1 100644 --- a/Source/HUDConfig.swift +++ b/Source/HUDConfig.swift @@ -8,6 +8,7 @@ import UIKit +@available(iOS 13.0, *) fileprivate var sharedWindowScene: UIWindowScene? /// HUD配置 public extension ProHUD { @@ -19,22 +20,14 @@ public extension ProHUD { /// 根控制器,默认可以自动获取,如果获取失败请主动设置 public var rootViewController: UIViewController? - /// iOS13必须设置此值,默认可以自动获取,如果获取失败请主动设置 - @available(iOS 13.0, *) - private static var sharedWindowScene: UIWindowScene? - /// iOS13必须设置此值,默认可以自动获取,如果获取失败请主动设置 @available(iOS 13.0, *) public var windowScene: UIWindowScene? { - set { - Configuration.sharedWindowScene = newValue - } - get { - return Configuration.sharedWindowScene - } + set { sharedWindowScene = newValue } + get { sharedWindowScene } } - /// 动态颜色(适配iOS13) + /// 动态颜色 public lazy var dynamicColor: UIColor = { if #available(iOS 13.0, *) { let color = UIColor { (traitCollection: UITraitCollection) -> UIColor in diff --git a/Source/HUDController.swift b/Source/HUDController.swift index 1584154..6d244a3 100644 --- a/Source/HUDController.swift +++ b/Source/HUDController.swift @@ -85,9 +85,7 @@ internal extension HUDController { } @objc func didTappedButton(_ sender: UIButton) { - if let ac = buttonEvents[sender] { - ac() - } + buttonEvents[sender]?() } } @@ -117,8 +115,8 @@ public extension LoadingAnimationView { v.updateProgress(progress: progress) } } - } + } /// 旋转动画 public protocol LoadingRotateAnimation: LoadingAnimationView {} diff --git a/Source/HUDUtils.swift b/Source/HUDUtils.swift index 005edbf..a9516ff 100644 --- a/Source/HUDUtils.swift +++ b/Source/HUDUtils.swift @@ -15,16 +15,16 @@ extension String { extension ProHUD { static var safeAreaInsets: UIEdgeInsets { - return Inspire.shared.screen.safeAreaInsets + Inspire.shared.screen.safeAreaInsets } } func == (left: ProHUD.Scene, right: ProHUD.Scene) -> Bool { - return left.identifier == right.identifier + left.identifier == right.identifier } func != (left: ProHUD.Scene, right: ProHUD.Scene) -> Bool { - return left.identifier != right.identifier + left.identifier != right.identifier } diff --git a/Source/ProHUD.swift b/Source/ProHUD.swift index 534e8d9..07a981b 100644 --- a/Source/ProHUD.swift +++ b/Source/ProHUD.swift @@ -12,22 +12,23 @@ public class ProHUD { public static let shared = ProHUD() - public var config: Configuration { - return cfg - } + public var config: Configuration { cfg } - public struct Scene { - private var id = "unknown" - public var identifier: String { - return id - } + +} + +// MARK: - Scene +public extension ProHUD { + + struct Scene { + public let identifier: String public var image: UIImage? public var alertDuration: TimeInterval? public var toastDuration: TimeInterval? = 3 public var title: String? public var message: String? - init() { - + public init(identifier: String) { + self.identifier = identifier } } @@ -35,10 +36,6 @@ public class ProHUD { // 默认场景,可直接在项目工程中覆写场景参数 public extension ProHUD.Scene { - init(identifier: String) { - self.init() - id = identifier - } static var `default`: ProHUD.Scene { var scene = ProHUD.Scene.init(identifier: "prohud.default") scene.image = ProHUD.image(named: "prohud.note") diff --git a/Source/Toast/ToastConfig.swift b/Source/Toast/ToastConfig.swift index f3d7f46..0b3616b 100644 --- a/Source/Toast/ToastConfig.swift +++ b/Source/Toast/ToastConfig.swift @@ -53,7 +53,7 @@ public extension ProHUD.Configuration { // MARK: - 内部调用 -internal extension ProHUD.Configuration.Toast { +extension ProHUD.Configuration.Toast { var reloadData: (ProHUD.Toast) -> Void { return privReloadData diff --git a/Source/Toast/ToastController.swift b/Source/Toast/ToastController.swift index 19a0222..ea288ab 100644 --- a/Source/Toast/ToastController.swift +++ b/Source/Toast/ToastController.swift @@ -13,7 +13,7 @@ public typealias Toast = ProHUD.Toast public extension ProHUD { class Toast: HUDController { - internal static var toasts = [Toast]() + static var toasts = [Toast]() public var window: UIWindow? @@ -66,7 +66,7 @@ public extension ProHUD { /// 视图模型 public var vm = ViewModel() - internal var maxY = CGFloat(0) + var maxY = CGFloat(0) // MARK: 生命周期 @@ -120,9 +120,7 @@ public extension Toast { let window = UIWindow(frame: .zero) self.window = window if #available(iOS 13.0, *) { - window.windowScene = cfg.windowScene ?? UIApplication.shared.windows.first?.windowScene - } else { - // Fallback on earlier versions + window.windowScene = cfg.windowScene ?? .currentWindowScene } window.windowLevel = .proToast window.backgroundColor = .clear @@ -270,11 +268,7 @@ public extension Toast { class func pop(_ toast: Toast) { toast.willDisappearCallback?() if toasts.count > 1 { - for (i, t) in toasts.enumerated() { - if t == toast { - toasts.remove(at: i) - } - } + toasts.removeAll { $0 == toast } privUpdateToastsLayout() } else if toasts.count == 1 { toasts.removeAll() diff --git a/Source/Toast/ToastModel.swift b/Source/Toast/ToastModel.swift index ebfd3da..c1cd993 100644 --- a/Source/Toast/ToastModel.swift +++ b/Source/Toast/ToastModel.swift @@ -47,12 +47,12 @@ public extension Toast { // MARK: 私有 /// 持续时间 - internal var durationBlock: DispatchWorkItem? + var durationBlock: DispatchWorkItem? /// 点击事件回调 - internal var tapCallback: (() -> Void)? + var tapCallback: (() -> Void)? - internal func updateDuration() { + func updateDuration() { durationBlock?.cancel() if let t = duration ?? scene.toastDuration, t > 0 { durationBlock = DispatchWorkItem(block: { [weak self] in