Activity Indicator In Xamarin.iOS


In this article, we are going to create a simple Xamarin.iOS application that will have the activity indicating some background task is going on. We will use an activity indicator that will animate on the specific duration indicating some calculation or functionality executing in the background. It lets the user know that some background task is going on.


  1. Knowledge of C#.
  2. Basics of Xamarin.

This article will cover the following.

  1. Single View app in Xamarin iOS.
  2. Activity Indicator View.


Open Visual Studio Community Edition.


Select Single View app and click "Next".


Give an application name and click "Next".


Set the project and solution name and its location and click on the "Create" button.

From the solution tab, open Main.storyboard. Disable the "Use size classes".


Go to the toolbox pad and search for Activity Indicator View.


Drag this view to your View Controller.

It will look very small so you have to set the style to make it visibly big. You can also set its color, background color, and different properties accordingly. Set the Name property so as to make it accessible to your viewController file.


Add two labels from the toolbox. Set the text property of one of the labels and empty the second label.

Your screen will look like this. Set the background color of View controller accordingly.


Your screen will look like this.


Open ViewController.cs and modify its ViewDidLoad method.


In the above code, we have used MyActivityIndicator.StartAnimating() function to start the animation; then we are delaying its thread for 10 seconds and then stopping the animation. We have to hide the animation view item, otherwise, it will only stop animating but still be visible static there.

Let us start the application. Build and run it.


You can see that the animation is going on and once it complete, after 10 seconds it will stop and hide from the View. Then, we are setting some message to the second label.


In this way, you can use the activity indicator with any kind of application, either in single view or in tabbed view. Wherever you want, the activity indicator should work. In case of any background fetching of data or loading of information, we can use this view and let the user know something background task is being done.


Build smarter apps with Machine Learning, Bots, Cognitive Services - Start free.

Start Learning Now