How to Give Your ViewController an Activity Indicator

How to Give Your ViewController an Activity Indicator

An Activity Indicator is a spinning wheel that indicates a task is being ... Select the Assistant Editor and make sure the ViewController.

UIKit provides a nifty little spinning wheel we can display to the user when we’re waiting on something that the user can’t see. It’s considered a best practice to pop one of these up when doing something like a network call, so the person using our app isn’t clueless as to what’s going on. Basically, you create the spinner, and add it to your view. Then, just before a background task like an API request, tell it to animate. When the background request finishes, you just tell it to stop animating.

First, declare your spinner in the ViewController

var activityIndicator = UIActivityIndicatorView(style: .Large)

Inside viewDidLoad, or a method called by viewDidLoad, add the spinner to your view

activityIndicator.translatesAutoresizingMaskIntoConstraints = false

activityIndicator.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
activityIndicator.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true

Before you make your background task, start the spinner


And when the background task completes, stop the spinner!


This is such a small UI feature that has a huge benefit. If you implement it correctly, the people that use your app will probably never consciously notice it. But if you don’t implement this, users will likely feel like your app is slow, or mistake a normal wait time for a buggy freeze of the app. Hope you got some value out of this, I know your users will!

swift ios-app-development programming user-experience ios activity indicator

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

How long does it take to develop/build an app?

This article covers A-Z about the mobile and web app development process and answers your question on how long does it take to develop/build an app.

Hire iOS App Developer

Are you looking to transform your idea into an iPhone application? Hire iPhone programmer team from **[]( "")** to ensure the best results, utilizing all the latest trends in iOS app...

iOS(iPhone OS) App Development Services

Skenix Infotech is a leading iPhone app development company with skilled & expert iOS app developers. Hire us to get affordable iPhone app development services.

Top iOS Mobile App Development Agency in New York

Are you looking for a [Top iOS Mobile App Development Agency in New York]**(**ment-company/ "Top iOS Mobile App Development Agency in New York") for your app projects? Then AppClues Infotech is the...

Custom iOS App Development Company New York

Hire the best iOS mobile app development company in New York, AppClues Infotech specialized in custom iOS app development and design services.