Created
January 25, 2016 05:14
-
-
Save pai911/a6e1c3addbfcb52355a7 to your computer and use it in GitHub Desktop.
Revisions
-
pai911 created this gist
Jan 25, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ import Foundation public class LoadingSpinnerOverlay{ var overlayView = UIView() var activityIndicator = UIActivityIndicatorView() class var shared: LoadingSpinnerOverlay { struct Static { static let instance = LoadingSpinnerOverlay() } return Static.instance } public func showOverlayOnView(view: UIView) { overlayView.frame = CGRect(x: 0, y: 0, width: 80, height: 80) overlayView.center = view.center overlayView.backgroundColor = UIColor.grayColor().colorWithAlphaComponent(0.5) overlayView.clipsToBounds = true overlayView.layer.cornerRadius = 10 activityIndicator.frame = CGRect(x: 0, y: 0, width: 40, height: 40) activityIndicator.activityIndicatorViewStyle = .WhiteLarge activityIndicator.center = CGPointMake(overlayView.bounds.width / 2, overlayView.bounds.height / 2) overlayView.addSubview(activityIndicator) view.addSubview(overlayView) activityIndicator.startAnimating() } public func hideOverlayView() { activityIndicator.stopAnimating() overlayView.removeFromSuperview() } }