It’s important to let users know when something is happening in the background with your app.

There are a few ways of showing that something is going on such as pop-up messages and progress bars but quite often you will see a ‘spinner’ known as an Activity Indicator in iOS.

It’s easy to implement a generic activity indicator in you app:

class ViewController: UIViewController {

var actInd: UIActivityIndicatorView = UIActivityIndicatorView(frame: CGRectMake(0, 0, 150, 150)) as UIActivityIndicatorView

    override func viewDidLoad() {
        super.viewDidLoad()

        self.actInd.center = self.view.center
        self.actInd.hidesWhenStopped = true
        self.actInd.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.Gray
        view.addSubview(self.actInd)

You can then use:

self.act.startAnimating()

to display the activity indicator and start its animation, or:

self.act.stopAnimating()

to stop the activity indicator’s animation and also hide it from the view.