I am using http communication in My iPhone app. I want to show a progress bar while it is loading data from server. How can I do it programmatically?
I just want a d
Swift 5.x version of @enrique7mc's Swift code:
var indicator: UIActivityIndicatorView = UIActivityIndicatorView(style: UIActivityIndicatorView.Style.gray)
indicator.frame = CGRect(x: 0.0, y: 0.0, width: 40.0, height: 40.0)
indicator.center = view.center
view.addSubview(indicator)
indicator.bringSubviewToFront(view)
UIApplication.shared.isNetworkActivityIndicatorVisible = true
Start it with
indicator.startAnimating()
Stop it with
indicator.stopAnimating()
This adds a small ActivityIndicator (turning circle, Apple's documentation) to the middle of the screen and to the status bar. The first one will be cleared once you switch to a different ViewController, while the one in the status bar won't - you have to manually disable it.