SwiftUI Activity Indicator 👇

Get Started

I hope, you have some basic knowledge on SwiftUI framework. So I am starting with activity indicator code.

In Depth

Now, I will draw simple activity indicator as you have seen in the top gif image.

  1. First created a View which returns the ‘ProgressView’ and takes two parameters — tintColor & scaleSize. Where tintColor is the activity indicator color and scaleSize is to set the size of indicator. Here setting the ‘ProgressView’ style as ‘CircularProgressViewStyle’ with tintColor.
  2. Then, in the body of ContentView, vertically, I added this LoaderView with a button. This button has action to show/hide the activity loader and simultaneously changing the text of button.
  3. I also done some other stuff. e.g. Created a View extension to show/hide a view in a smooth manner. Added some padding between LoaderView & Button.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store