Created
March 6, 2017 14:31
-
-
Save ruan65/3d7761fa52eb1038295fba07690d0168 to your computer and use it in GitHub Desktop.
iOs swift activity indicator
This file contains hidden or 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
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