Skip to content

Instantly share code, notes, and snippets.

@samirGuerdah
Created January 18, 2018 22:28
Show Gist options
  • Save samirGuerdah/70a7b82178bef274398c93c5baa39c0c to your computer and use it in GitHub Desktop.
Save samirGuerdah/70a7b82178bef274398c93c5baa39c0c to your computer and use it in GitHub Desktop.
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