Skip to content

Instantly share code, notes, and snippets.

@giln
Created May 6, 2019 13:28
Show Gist options
  • Save giln/9de8bd4546b88234290c56ba6836f907 to your computer and use it in GitHub Desktop.
Save giln/9de8bd4546b88234290c56ba6836f907 to your computer and use it in GitHub Desktop.
import UIKit
open class LoadingViewController: UIViewController {
// MARK: - Variables
public let activityIndicator = UIActivityIndicatorView(style: .gray)
// MARK: - Lifecycle
open override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = UIColor.white
activityIndicator.hidesWhenStopped = true
view.addSubview(activityIndicator)
activityIndicator.center(in: view)
}
open override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
activityIndicator.startAnimating()
}
open override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
activityIndicator.stopAnimating()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment