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.hidesWhenStopped = true
        self.actInd.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.Gray

You can then use:


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


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