How to show the loading indicator in the top status bar

Viewed 48344

I have noticed that some apps like Safari and Mail show a loading indicator in the status bar (the bar at the very top of the phone) when they are accessing the network. Is there a way to do the same thing in SDK apps, or is this an Apple only thing?

8 Answers

It's in UIApplication:

For Objective C:

Start:

[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;

End:

[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;

For swift :

Start

UIApplication.shared.isNetworkActivityIndicatorVisible = true

End

UIApplication.shared.isNetworkActivityIndicatorVisible = false

The status bar network activity indicator was deprecated in iOS 13.

Using UIApplication.shared.isNetworkActivityIndicatorVisible = true will not work anymore.

The deprecation message says:

Provide a custom network activity UI in your app if desired.

As many have said, there is no network activity indicator for the iPhone X and probably for the other new iPhones with the notch.

I came across this incredible library written by Ortwin Gentz, FutureTap: https://github.com/futuretap/FTLinearActivityIndicator

It puts the indicator right back where it was when the iPhone X was initially released, many would remember the Knight Rider type of indicator.

This library is available for Swift 4.2, so you will need to change the Swift Language settings, as described here: Type 'NSAttributedStringKey' (aka 'NSString') has no member 'font'

Related