I have some swift code for an iOS app that looks like this:
@IBOutlet weak var activity: UIActivityIndicatorView!
@IBAction func Button(_ sender: Any) {
activity.isHidden = false
activity.startAnimating()
[My code]
activity.stopAnimating()
activity.isHidden = true
}
But when the function is running the activity indicator doesn't appear, and if I remove:
activity.stopAnimating()
activity.isHidden = true
It will appear when the function is done, so in some way the activity indicator first appears when the function have finished(?)
So my question is: How do I make the activity indicator view stay active only when the function is running?