Last active
October 27, 2018 14:06
-
-
Save marcos1262/8028e1b4a7eb56339a26ce5121d98fbc to your computer and use it in GitHub Desktop.
Spinner indicator to put over loading views
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIViewController { | |
func displaySpinner(onView : UIView) -> UIView { | |
let spinnerView = UIView.init(frame: onView.bounds) | |
spinnerView.backgroundColor = UIColor.white //UIColor.black.withAlphaComponent(0.5) | |
let ai = UIActivityIndicatorView(style: .gray) | |
ai.startAnimating() | |
ai.center = spinnerView.center | |
DispatchQueue.main.async { | |
spinnerView.addSubview(ai) | |
onView.addSubview(spinnerView) | |
} | |
return spinnerView | |
} | |
func removeSpinner(spinner :UIView) { | |
DispatchQueue.main.async { | |
spinner.removeFromSuperview() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment