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
|
||||
}
|
||||
|
||||
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
|
||||
if vc.model.title?.count ?? 0 > 0 || vc.model.message?.count ?? 0 > 0 {
|
||||
vc.contentStack.addArrangedSubview(vc.textStack)
|
||||
|
@ -263,6 +271,15 @@ fileprivate var privReloadData: (ProHUD.Alert) -> Void = {
|
|||
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.message = message
|
||||
model.icon = icon
|
||||
switch scene {
|
||||
case .loading:
|
||||
model.duration = nil
|
||||
default:
|
||||
model.duration = 2
|
||||
}
|
||||
|
||||
willLayoutSubviews()
|
||||
|
||||
|
@ -166,7 +160,7 @@ public extension ProHUD.Alert {
|
|||
model.scene = scene
|
||||
model.title = title
|
||||
model.message = message
|
||||
cfg.alert.reloadData(self)
|
||||
willLayoutSubviews()
|
||||
return self
|
||||
}
|
||||
|
||||
|
@ -175,6 +169,7 @@ public extension ProHUD.Alert {
|
|||
@discardableResult func update(icon: UIImage?) -> ProHUD.Alert {
|
||||
model.icon = icon
|
||||
cfg.alert.reloadData(self)
|
||||
imageView?.layer.removeAllAnimations()
|
||||
return self
|
||||
}
|
||||
|
||||
|
@ -230,18 +225,20 @@ public extension ProHUD {
|
|||
/// 推入屏幕
|
||||
/// - Parameter alert: 实例
|
||||
@discardableResult func push(_ alert: Alert) -> Alert {
|
||||
let window = getAlertWindow(alert)
|
||||
window.makeKeyAndVisible()
|
||||
window.resignKey()
|
||||
window.addSubview(alert.view)
|
||||
alert.view.transform = .init(scaleX: 1.2, y: 1.2)
|
||||
alert.view.alpha = 0
|
||||
UIView.animateForAlertBuildIn {
|
||||
alert.view.transform = .identity
|
||||
alert.view.alpha = 1
|
||||
window.backgroundColor = window.backgroundColor?.withAlphaComponent(0.6)
|
||||
if alerts.contains(alert) == false {
|
||||
let window = getAlertWindow(alert)
|
||||
window.makeKeyAndVisible()
|
||||
window.resignKey()
|
||||
window.addSubview(alert.view)
|
||||
alert.view.transform = .init(scaleX: 1.2, y: 1.2)
|
||||
alert.view.alpha = 0
|
||||
UIView.animateForAlertBuildIn {
|
||||
alert.view.transform = .identity
|
||||
alert.view.alpha = 1
|
||||
window.backgroundColor = window.backgroundColor?.withAlphaComponent(0.6)
|
||||
}
|
||||
alerts.append(alert)
|
||||
}
|
||||
alerts.append(alert)
|
||||
updateAlertsLayout()
|
||||
// setup duration
|
||||
if let _ = alert.model.duration, alert.model.durationBlock == nil {
|
||||
|
@ -436,7 +433,9 @@ fileprivate extension ProHUD {
|
|||
if alerts.count > 1 {
|
||||
for (i, a) in alerts.enumerated() {
|
||||
if a == alert {
|
||||
alerts.remove(at: i)
|
||||
if i < alerts.count {
|
||||
alerts.remove(at: i)
|
||||
}
|
||||
}
|
||||
}
|
||||
updateAlertsLayout()
|
||||
|
|
|
@ -17,7 +17,7 @@ public class HUDController: UIViewController {
|
|||
internal var disappearCallback: (() -> Void)?
|
||||
|
||||
/// 按钮事件
|
||||
internal var buttonEvents = [UIButton:() -> Void]()
|
||||
fileprivate var buttonEvents = [UIButton:() -> Void]()
|
||||
|
||||
init() {
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
|
|
|
@ -33,8 +33,11 @@ public extension ProHUD {
|
|||
|
||||
if #available(iOS 13.0, *) {
|
||||
super.init(effect: UIBlurEffect(style: .systemMaterial))
|
||||
} else {
|
||||
} else if #available(iOS 11.0, *) {
|
||||
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()
|
||||
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.message = message
|
||||
model.icon = icon
|
||||
switch scene {
|
||||
case .loading:
|
||||
model.duration = nil
|
||||
default:
|
||||
model.duration = 2
|
||||
}
|
||||
|
||||
// 布局
|
||||
cfg.toast.loadSubviews(self)
|
||||
|
|
Loading…
Reference in New Issue