如何打开 iOS 状态栏中的网络指示灯?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10299889/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 18:02:14  来源:igfitidea点击:

How to turn on the network indicator in the iOS status bar?

iosswiftnetworking

提问by JustSid

I am aware there is more than one of these indicators. Thanks.

我知道这些指标不止一个。谢谢。

回答by sasquatch

Swift

迅速

UIApplication.sharedApplication().networkActivityIndicatorVisible = true

Swift 5, Swift 4.x, Swift 3.x

斯威夫特 5斯威夫特 4.x斯威夫特 3.x

UIApplication.shared.isNetworkActivityIndicatorVisible = true

Update for iOS 13

iOS 13更新

It seems there will be no network indicator displayed from iOS 13.

iOS 13 似乎不会显示网络指示器。

The deprecationmessage says:

弃用的消息说:

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

如果需要,请在您的应用中提供自定义网络活动 UI。

回答by JustSid

[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];