Created
January 18, 2018 22:28
-
-
Save samirGuerdah/70a7b82178bef274398c93c5baa39c0c to your computer and use it in GitHub Desktop.
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 characters
protocol Loadable { | |
var activityIndicator: UIActivityIndicatorView {get} | |
func showLoaderView() | |
func hideLoaderView() | |
} | |
extension Loadable where Self: UIViewController { | |
func showLoaderView() { | |
activityIndicator.translatesAutoresizingMaskIntoConstraints = false | |
view.addSubview(activityIndicator) | |
activityIndicator.startAnimating() | |
// Layout | |
// ... | |
} | |
func hideLoaderView() { | |
activityIndicator.stopAnimating() | |
loaderBackgroundView.removeFromSuperview() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment