ZoneHUD.swift 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //
  2. // ZoneHUD.swift
  3. // O2Platform
  4. //
  5. // Created by 刘振兴 on 2017/3/16.
  6. // Copyright © 2017年 zoneland. All rights reserved.
  7. //
  8. import UIKit
  9. import JGProgressHUD
  10. class ZoneHUD: NSObject {
  11. private static var hud:JGProgressHUD {
  12. struct HUDWrapper {
  13. static let myHUD = JGProgressHUD(style: .light)
  14. }
  15. HUDWrapper.myHUD.interactionType = .blockAllTouches
  16. HUDWrapper.myHUD.animation = JGProgressHUDFadeZoomAnimation()
  17. HUDWrapper.myHUD.backgroundColor = UIColor.init(white: 0.0, alpha: 0.2)
  18. return HUDWrapper.myHUD
  19. }
  20. public class func showNormalHUD(_ parentView:UIView,_ text:String = "loading...") {
  21. ZoneHUD.hud.indicatorView = JGProgressHUDIndicatorView()
  22. ZoneHUD.hud.textLabel.text = text
  23. ZoneHUD.hud.show(in: parentView, animated: true)
  24. }
  25. public class func showSuccessHUD(successText text:String = "success",_ afterDelay:Double = 0.5){
  26. hud.textLabel.text = text
  27. hud.layoutChangeAnimationDuration = 0.3
  28. hud.indicatorView = JGProgressHUDSuccessIndicatorView()
  29. Timer.after(afterDelay) {
  30. //perationQueue.main.addOperation {
  31. hud.dismiss()
  32. //}
  33. }
  34. }
  35. public class func showErrorHUD(errorText text:String = "error",_ afterDelay:Double = 0.5){
  36. hud.textLabel.text = text
  37. hud.layoutChangeAnimationDuration = 0.3
  38. hud.indicatorView = JGProgressHUDErrorIndicatorView()
  39. Timer.after(afterDelay) {
  40. //DispatchQueue.main.async {
  41. ZoneHUD.hud.dismiss()
  42. //}
  43. }
  44. }
  45. public class func dismissNormalHUD(){
  46. hud.dismiss()
  47. }
  48. }