Activity Indicator View
An ActivityIndicator is a type of content view that may be used to display the status of a task, and it's mostly utilized for intra-network communications. Methods defined in the UIActivityIndicatorView class may be used to manipulate the ActivityIndicator View, and UIActivityIndicatorView is a UIView subclass.
- class UIActivityIndicatorView : UIView
The animation may be started using the UIActivityIndicatorView class's startAnimating() function. Stopping the animation may also be done with the stopAnimating() function. In the iOS application, the two techniques are combined to show and conceal the activity indicator.
Adding UIActivityIndicatorView to interface
- In the object library, look for UIActivityIndicatorView and drag it to the storyboard.
- Define the Auto Layout rules to control the size and placement of the activity indicator on devices of various sizes.
- Create an ActivityIndicator action outlet in the ViewController class.
- Using the methods and attributes described in the UIActivityIndicatorView class to start and stop the animation.
- activityIndicator is a new private method. As previously stated, this technique requires three parameters. For some flexibility, all of the options have a default value. Because there are only two possibilities for style,.large or.medium, I've chosen.medium as the default. Finally, we have a central argument, which allows us to establish a frame if we want to. We'll be able to pass a center point for our activity indicator due to this. You'll have to manually compute the center point based on the size of the frame if you utilize the center and frame combined.
- With style provided as input, we create a UIActivityIndicatorView.
We'll set the activityIndicatorView frame if we have one.
We will set the center of our activityIndicatorView if we have a center point, and the activity indication should be returned.
All left to do now is execute this method and add the activity view as a subview. This is something I'm going to perform in my viewDidLoad function.