Created
December 6, 2017 20:40
-
-
Save regnerjr/8a8d1f7460966c046847568655864085 to your computer and use it in GitHub Desktop.
A little view controller that shows a loading indicator. (great for using as a placeholder VC while your parent does a network request)
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
class LoadingVC: UIViewController { | |
lazy var loadingIndicator: UIActivityIndicatorView = { | |
let loading = UIActivityIndicatorView(activityIndicatorStyle: UIActivityIndicatorViewStyle.gray) | |
return loading | |
}() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
view.backgroundColor = .white | |
loadingIndicator.frame = view.bounds | |
view.addSubview(loadingIndicator) | |
} | |
override func viewWillAppear(_ animated: Bool) { | |
super.viewWillAppear(animated) | |
loadingIndicator.startAnimating() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment