Skip to content

Instantly share code, notes, and snippets.

@RockinPaul
Last active March 21, 2018 22:03
Show Gist options
  • Save RockinPaul/8bb5d325d575591bdcef44a87c41b09a to your computer and use it in GitHub Desktop.
Save RockinPaul/8bb5d325d575591bdcef44a87c41b09a to your computer and use it in GitHub Desktop.
fileprivate var activityIndicator : UIImageView! = UIImageView(image: UIImage.gif(name:"load")) // load.gif file
override func viewDidLoad() {
super.viewDidLoad()
self.activityIndicator.frame = CGRect(x: 0, y: 0, width: 50, height: 50)
self.activityIndicator.contentMode = .scaleAspectFit
self.activityIndicator.backgroundColor = UIColor.clear
}
fileprivate func showActivityIndicator() {
self.view.addSubview(self.activityIndicator)
self.activityIndicator.center = self.view.center
self.activityIndicator.startAnimating()
}
fileprivate func hideActivityIndicator() {
self.activityIndicator.stopAnimating()
self.activityIndicator.removeFromSuperview()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment