I'm currently attempting to make a global activity indicator in swift, which is called whenever a fetch to the api is made. The idea is that the activity indicator will appear in the top left of a navigation bar (navigation view controller's child), and is available on every app page.
Can't show example image due to new account / low rep
I have the activity indicator displaying correctly, I'm just not sure on how to make it available from any page on the app - i've considered an extension, but am not sure on what the best way to approach it is. Any help would be greatly appreciated.
Activity Indicator Code:
let activityIndicator: UIActivityIndicatorView = UIActivityIndicatorView(activityIndicatorStyle: UIActivityIndicatorViewStyle.White)
var activityItem = UIBarButtonItem()
func navBarActivity() {
// Call navBarActivity() to start activity indicator
// Use navigationItem.leftBarButtonItem = nil to stop activity indicator
activityIndicator.startAnimating()
activityIndicator.hidden = false
self.activityItem = UIBarButtonItem(customView: activityIndicator)
self.navigationItem.leftBarButtonItem = activityItem
}