Skip to content

Instantly share code, notes, and snippets.

@lamarmarshall
Last active March 3, 2017 04:35
Show Gist options
  • Save lamarmarshall/f8b930ac4993c77e134f1c007b93f994 to your computer and use it in GitHub Desktop.
Save lamarmarshall/f8b930ac4993c77e134f1c007b93f994 to your computer and use it in GitHub Desktop.
swift spinner progressbar indicator
var spinning: Bool = false
var spinner = UIActivityIndicatorView()
@IBAction func spin(_ sender: Any) {
if !spinning {
spinner = UIActivityIndicatorView(frame: CGRect(x: 0, y: 0, width: 200, height: 200 ) )
spinner.center = self.view.center
spinner.hidesWhenStopped = true
spinner.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.gray
view.addSubview(spinner)
spinner.startAnimating()
spinning = true
// UIApplication.shared.beginIgnoringInteractionEvents()
}else{
spinner.stopAnimating()
spinning = false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment