TSToastTool.swift 915 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //
  2. // TSToastTool.swift
  3. // TSLiveWallpaper
  4. //
  5. // Created by 100Years on 2024/12/20.
  6. //
  7. import SVProgressHUD
  8. let TSToastShared = TSToastTool.shared
  9. class TSToastTool {
  10. static let shared = TSToastTool()
  11. private init() {
  12. SVProgressHUD.setDefaultStyle(.dark)
  13. //如果您想要堆叠 HUD,您可以使用以下方法平衡每个节目通话:
  14. //[SVProgressHUD popActivity];
  15. }
  16. /// 显示文字提示
  17. func showToast(text: String, duration: TimeInterval = 3.0) {
  18. kExecuteOnMainThread {
  19. SVProgressHUD.showInfo(withStatus: text)
  20. }
  21. }
  22. /// 显示加载动画
  23. func showLoading(text:String? = nil) {
  24. kExecuteOnMainThread {
  25. SVProgressHUD.show(withStatus: text)
  26. }
  27. }
  28. /// 隐藏加载动画
  29. func hideLoading() {
  30. kExecuteOnMainThread {
  31. SVProgressHUD.dismiss()
  32. }
  33. }
  34. }