mirror of https://github.com/xaoxuu/ProHUD
update
This commit is contained in:
parent
d182b5fede
commit
0da83c80b5
|
@ -165,7 +165,15 @@ fileprivate var privReloadData: (ProHUD.Alert) -> Void = {
|
||||||
}
|
}
|
||||||
vc.imageView = icon
|
vc.imageView = icon
|
||||||
}
|
}
|
||||||
|
if vc.model.scene == .loading {
|
||||||
|
let ani = CABasicAnimation(keyPath: "transform.rotation.z")
|
||||||
|
ani.toValue = M_PI*2.0
|
||||||
|
ani.duration = 2
|
||||||
|
ani.repeatCount = 10000
|
||||||
|
vc.imageView?.layer.add(ani, forKey: "rotationAnimation")
|
||||||
|
} else {
|
||||||
|
vc.imageView?.layer.removeAllAnimations()
|
||||||
|
}
|
||||||
// text
|
// text
|
||||||
if vc.model.title?.count ?? 0 > 0 || vc.model.message?.count ?? 0 > 0 {
|
if vc.model.title?.count ?? 0 > 0 || vc.model.message?.count ?? 0 > 0 {
|
||||||
vc.contentStack.addArrangedSubview(vc.textStack)
|
vc.contentStack.addArrangedSubview(vc.textStack)
|
||||||
|
@ -263,6 +271,15 @@ fileprivate var privReloadData: (ProHUD.Alert) -> Void = {
|
||||||
vc.view.layoutIfNeeded()
|
vc.view.layoutIfNeeded()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
switch vc.model.scene {
|
||||||
|
case .loading:
|
||||||
|
vc.model.duration = nil
|
||||||
|
default:
|
||||||
|
vc.model.duration = 2
|
||||||
|
}
|
||||||
|
if vc.actionStack.arrangedSubviews.count > 0 {
|
||||||
|
vc.model.duration = nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|
|
@ -64,12 +64,6 @@ public extension ProHUD {
|
||||||
model.title = title
|
model.title = title
|
||||||
model.message = message
|
model.message = message
|
||||||
model.icon = icon
|
model.icon = icon
|
||||||
switch scene {
|
|
||||||
case .loading:
|
|
||||||
model.duration = nil
|
|
||||||
default:
|
|
||||||
model.duration = 2
|
|
||||||
}
|
|
||||||
|
|
||||||
willLayoutSubviews()
|
willLayoutSubviews()
|
||||||
|
|
||||||
|
@ -166,7 +160,7 @@ public extension ProHUD.Alert {
|
||||||
model.scene = scene
|
model.scene = scene
|
||||||
model.title = title
|
model.title = title
|
||||||
model.message = message
|
model.message = message
|
||||||
cfg.alert.reloadData(self)
|
willLayoutSubviews()
|
||||||
return self
|
return self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,6 +169,7 @@ public extension ProHUD.Alert {
|
||||||
@discardableResult func update(icon: UIImage?) -> ProHUD.Alert {
|
@discardableResult func update(icon: UIImage?) -> ProHUD.Alert {
|
||||||
model.icon = icon
|
model.icon = icon
|
||||||
cfg.alert.reloadData(self)
|
cfg.alert.reloadData(self)
|
||||||
|
imageView?.layer.removeAllAnimations()
|
||||||
return self
|
return self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,18 +225,20 @@ public extension ProHUD {
|
||||||
/// 推入屏幕
|
/// 推入屏幕
|
||||||
/// - Parameter alert: 实例
|
/// - Parameter alert: 实例
|
||||||
@discardableResult func push(_ alert: Alert) -> Alert {
|
@discardableResult func push(_ alert: Alert) -> Alert {
|
||||||
let window = getAlertWindow(alert)
|
if alerts.contains(alert) == false {
|
||||||
window.makeKeyAndVisible()
|
let window = getAlertWindow(alert)
|
||||||
window.resignKey()
|
window.makeKeyAndVisible()
|
||||||
window.addSubview(alert.view)
|
window.resignKey()
|
||||||
alert.view.transform = .init(scaleX: 1.2, y: 1.2)
|
window.addSubview(alert.view)
|
||||||
alert.view.alpha = 0
|
alert.view.transform = .init(scaleX: 1.2, y: 1.2)
|
||||||
UIView.animateForAlertBuildIn {
|
alert.view.alpha = 0
|
||||||
alert.view.transform = .identity
|
UIView.animateForAlertBuildIn {
|
||||||
alert.view.alpha = 1
|
alert.view.transform = .identity
|
||||||
window.backgroundColor = window.backgroundColor?.withAlphaComponent(0.6)
|
alert.view.alpha = 1
|
||||||
|
window.backgroundColor = window.backgroundColor?.withAlphaComponent(0.6)
|
||||||
|
}
|
||||||
|
alerts.append(alert)
|
||||||
}
|
}
|
||||||
alerts.append(alert)
|
|
||||||
updateAlertsLayout()
|
updateAlertsLayout()
|
||||||
// setup duration
|
// setup duration
|
||||||
if let _ = alert.model.duration, alert.model.durationBlock == nil {
|
if let _ = alert.model.duration, alert.model.durationBlock == nil {
|
||||||
|
@ -436,7 +433,9 @@ fileprivate extension ProHUD {
|
||||||
if alerts.count > 1 {
|
if alerts.count > 1 {
|
||||||
for (i, a) in alerts.enumerated() {
|
for (i, a) in alerts.enumerated() {
|
||||||
if a == alert {
|
if a == alert {
|
||||||
alerts.remove(at: i)
|
if i < alerts.count {
|
||||||
|
alerts.remove(at: i)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateAlertsLayout()
|
updateAlertsLayout()
|
||||||
|
|
|
@ -17,7 +17,7 @@ public class HUDController: UIViewController {
|
||||||
internal var disappearCallback: (() -> Void)?
|
internal var disappearCallback: (() -> Void)?
|
||||||
|
|
||||||
/// 按钮事件
|
/// 按钮事件
|
||||||
internal var buttonEvents = [UIButton:() -> Void]()
|
fileprivate var buttonEvents = [UIButton:() -> Void]()
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
super.init(nibName: nil, bundle: nil)
|
super.init(nibName: nil, bundle: nil)
|
||||||
|
|
|
@ -33,8 +33,11 @@ public extension ProHUD {
|
||||||
|
|
||||||
if #available(iOS 13.0, *) {
|
if #available(iOS 13.0, *) {
|
||||||
super.init(effect: UIBlurEffect(style: .systemMaterial))
|
super.init(effect: UIBlurEffect(style: .systemMaterial))
|
||||||
} else {
|
} else if #available(iOS 11.0, *) {
|
||||||
super.init(effect: UIBlurEffect(style: .extraLight))
|
super.init(effect: UIBlurEffect(style: .extraLight))
|
||||||
|
} else {
|
||||||
|
super.init(effect: .none)
|
||||||
|
backgroundColor = .white
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 2.5 KiB |
Binary file not shown.
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 3.3 KiB |
|
@ -123,5 +123,13 @@ fileprivate var privReloadData: (ProHUD.Toast) -> Void = {
|
||||||
}
|
}
|
||||||
|
|
||||||
vc.view.layoutIfNeeded()
|
vc.view.layoutIfNeeded()
|
||||||
|
switch vc.model.scene {
|
||||||
|
case .loading:
|
||||||
|
vc.model.duration = nil
|
||||||
|
default:
|
||||||
|
vc.model.duration = 3
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}()
|
}()
|
||||||
|
|
|
@ -71,12 +71,6 @@ public extension ProHUD {
|
||||||
model.title = title
|
model.title = title
|
||||||
model.message = message
|
model.message = message
|
||||||
model.icon = icon
|
model.icon = icon
|
||||||
switch scene {
|
|
||||||
case .loading:
|
|
||||||
model.duration = nil
|
|
||||||
default:
|
|
||||||
model.duration = 2
|
|
||||||
}
|
|
||||||
|
|
||||||
// 布局
|
// 布局
|
||||||
cfg.toast.loadSubviews(self)
|
cfg.toast.loadSubviews(self)
|
||||||
|
|
Loading…
Reference in New Issue