From 4217c5a98ca4f384a891eb15e95b8499b5ba071a Mon Sep 17 00:00:00 2001 From: xaoxuu Date: Tue, 13 Aug 2019 09:14:30 +0800 Subject: [PATCH] update --- Example/Example/TestToastVC.swift | 3 ++- ProHUD/Alert/AlertController.swift | 4 ++-- ProHUD/Guard/GuardController.swift | 16 ++++++++-------- ProHUD/Toast/ToastController.swift | 19 ++++++++++++++++++- 4 files changed, 30 insertions(+), 12 deletions(-) diff --git a/Example/Example/TestToastVC.swift b/Example/Example/TestToastVC.swift index 72ff5c8..d8abb9c 100644 --- a/Example/Example/TestToastVC.swift +++ b/Example/Example/TestToastVC.swift @@ -89,7 +89,8 @@ class TestToastVC: BaseListVC { } } else if row == 7 { Toast.find("aaa", last: { (t) in - t.update { (vm) in + t.pulse() + t.update() { (vm) in vm.title = "已经存在了" } }) { diff --git a/ProHUD/Alert/AlertController.swift b/ProHUD/Alert/AlertController.swift index 73da546..5534f11 100644 --- a/ProHUD/Alert/AlertController.swift +++ b/ProHUD/Alert/AlertController.swift @@ -56,7 +56,7 @@ public extension ProHUD { public var vm = ViewModel() // MARK: 生命周期 - internal var isLoadFinished = false + private var isLoadFinished = false /// 实例化 /// - Parameter scene: 场景 @@ -180,7 +180,7 @@ public extension Alert { return Alert(scene: scene, title: title, message: message, actions: actions).push() } - /// 获取指定的实例 + /// 查找指定的实例 /// - Parameter identifier: 指定实例的标识 class func find(_ identifier: String?) -> [Alert] { var aa = [Alert]() diff --git a/ProHUD/Guard/GuardController.swift b/ProHUD/Guard/GuardController.swift index f84131d..578cc2e 100644 --- a/ProHUD/Guard/GuardController.swift +++ b/ProHUD/Guard/GuardController.swift @@ -49,7 +49,7 @@ public extension ProHUD { public var isFullScreen = false /// 是否正在显示 - private var displaying = false + private var isDisplaying = false /// 背景颜色 public var backgroundColor: UIColor? = UIColor(white: 0, alpha: 0.4) @@ -57,7 +57,7 @@ public extension ProHUD { public var vm = ViewModel() // MARK: 生命周期 - internal var isLoadFinished = false + private var isLoadFinished = false /// 实例化 /// - Parameter title: 标题 @@ -106,10 +106,10 @@ public extension Guard { view.snp.makeConstraints { (mk) in mk.edges.equalToSuperview() } - if displaying == false { + if isDisplaying == false { privTranslateOut() } - displaying = true + isDisplaying = true UIView.animateForGuard { self.privTranslateIn() } @@ -124,16 +124,16 @@ public extension Guard { /// 从父视图控制器弹出 func pop() { - if displaying { + if isDisplaying { debug("pop") willDisappearCallback?() - displaying = false + isDisplaying = false view.isUserInteractionEnabled = false self.removeFromParent() UIView.animateForGuard(animations: { self.privTranslateOut() }) { (done) in - if self.displaying == false { + if self.isDisplaying == false { self.view.removeFromSuperview() } } @@ -162,7 +162,7 @@ public extension Guard { return Guard(actions: actions).push(to: viewController) } - /// 获取指定的实例 + /// 查找指定的实例 /// - Parameter identifier: 指定实例的标识 class func find(_ identifier: String?, from viewController: UIViewController? = nil) -> [Guard] { var gg = [Guard]() diff --git a/ProHUD/Toast/ToastController.swift b/ProHUD/Toast/ToastController.swift index 1b71638..4c511b1 100644 --- a/ProHUD/Toast/ToastController.swift +++ b/ProHUD/Toast/ToastController.swift @@ -173,6 +173,8 @@ public extension Toast { vm.tapCallback = callback } + /// 图片旋转效果 + /// - Parameter rotate: 是否开启 func animate(rotate: Bool) { if rotate { DispatchQueue.main.async { @@ -187,6 +189,21 @@ public extension Toast { } } + /// 脉冲效果 + func pulse() { + DispatchQueue.main.async { + UIView.animate(withDuration: 0.2, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 1, options: [.allowUserInteraction, .curveEaseOut], animations: { + self.window?.transform = .init(scaleX: 1.04, y: 1.04) + }) { (done) in + UIView.animate(withDuration: 1, delay: 0, usingSpringWithDamping: 0.5, initialSpringVelocity: 1, options: [.allowUserInteraction, .curveEaseIn], animations: { + self.window?.transform = .identity + }) { (done) in + + } + } + } + } + } @@ -202,7 +219,7 @@ public extension Toast { return Toast(scene: scene, title: title, message: message, duration: duration, actions: actions).push() } - /// 获取指定的toast + /// 查找指定的实例 /// - Parameter identifier: 标识 class func find(_ identifier: String?) -> [Toast] { var tt = [Toast]()