Skip to content

Instantly share code, notes, and snippets.

@glennposadas
Created September 9, 2017 18:43
Show Gist options
  • Save glennposadas/bd0561500f27409f6610e9a01c502b30 to your computer and use it in GitHub Desktop.
Save glennposadas/bd0561500f27409f6610e9a01c502b30 to your computer and use it in GitHub Desktop.
SVProgressHUD Extension
//
// SVProgressHUD+FindWork.swift
// FindWork
//
// Created by Glenn Posadas on 1/20/17.
// Copyright © 2017 ThirtyOneDigital. All rights reserved.
//
import SVProgressHUD
import UIKit
extension SVProgressHUD {
/** Sets timeout for the HUD
*/
open class func show(_ status: String, maxTime: TimeInterval) {
SVProgressHUD.show(withStatus: status)
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + maxTime) {
SVProgressHUD.dismiss()
}
}
open class func show(maxTime: TimeInterval) {
SVProgressHUD.show(withStatus: "Please wait...")
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + maxTime) {
SVProgressHUD.dismiss()
}
}
open class func showSuccess(completion: (() -> Void)?) {
SVProgressHUD.showSuccess(withStatus: "Success!")
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 1.0) {
completion?()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment