Skip to content

Instantly share code, notes, and snippets.

@ruan65
Created March 6, 2017 14:31
Show Gist options
  • Save ruan65/3d7761fa52eb1038295fba07690d0168 to your computer and use it in GitHub Desktop.
Save ruan65/3d7761fa52eb1038295fba07690d0168 to your computer and use it in GitHub Desktop.
iOs swift activity indicator
var spinner: UIActivityIndicatorView!
func setupSpinner(){
spinner = UIActivityIndicatorView(frame: CGRect(x: 0, y: 0, width: 40, height:40))
spinner.color = UIColor.gray
self.spinner.center = CGPoint(x:UIScreen.main.bounds.size.width / 2, y:UIScreen.main.bounds.size.height / 2)
self.view.addSubview(spinner)
spinner.hidesWhenStopped = true
}
spinner.startAnimating()
DispatchQueue.main.async {
self.spinner.stopAnimating()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment