iOS 状态栏中的加载指示器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11068143/
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:49:24  来源:igfitidea点击:

Loading Indicator in Status Bar iOS

iosuistatusbarindicator

提问by RileyE

I'm trying to figure out what the loading circle animation in the status bar is. A lot of apps, when they load data, have a spinner in the status bar to indicate that the app is loading data, but I can't figure out what its called to implement it. Can someone tell me what it is called?

我想弄清楚状态栏中的加载圆圈动画是什么。许多应用程序在加载数据时,在状态栏中都有一个微调器,以指示该应用程序正在加载数据,但我无法弄清楚它调用了什么来实现它。谁能告诉我它叫什么?

If you don't know what I'm talking about, but have an iOS device, try loading a web page in Safari and look at the spinner in the status bar. Thats what I'm talking about.

如果您不知道我在说什么,但有 iOS 设备,请尝试在 Safari 中加载网页并查看状态栏中的微调器。我正是这个意思。

Here is an screenshot I took Its the spinner in the statusbar.

这是我截取的屏幕截图它是状态栏中的微调器

回答by Chris Trahey

I think what you are looking for is:

我认为你正在寻找的是:

[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;

Swift 3

斯威夫特 3

UIApplication.shared.isNetworkActivityIndicatorVisible = true

as doc'd here: https://developer.apple.com/documentation/uikit/uiapplication/1623102-isnetworkactivityindicatorvisibl

正如这里的文档:https: //developer.apple.com/documentation/uikit/uiapplication/1623102-isnetworkactivityindicatorvisibl

回答by RhodanV5500

Same as above just in Swift:

与上面相同,仅在 Swift 中:

UIApplication.sharedApplication().networkActivityIndicatorVisible = true

回答by 16patsle

For anyone looking for the answer to this is Swift 3, you just set the property isNetworkActivityIndicatorVisibleon UIApplicationto true.

为寻找这个问题的答案是斯威夫特3,您只需设置属性isNetworkActivityIndicatorVisibleUIApplication为true。

For instance in the didFinishLaunchingWithOptonsfunction in the app delegate:

例如在didFinishLaunchingWithOptons应用程序委托的函数中:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {        // Override point for customization after application launch.
    application.isNetworkActivityIndicatorVisible = true

    return true
}

Which basically means:

这基本上意味着:

UIApplication.sharedApplication().isNetworkActivityIndicatorVisible = true

回答by Evgeny Karkan

Swift 4

斯威夫特 4

UIApplication.shared.isNetworkActivityIndicatorVisible = true

回答by MCKapur

It is UIActivityIndicatorView. You can check out its documentation and learn more here: UIActivityIndicatorView

它是UIActivityIndicatorView。您可以查看其文档并在此处了解更多信息:UIActivityIndi​​catorView

Also, to put it on the status bar, check out this link: Activity Monitor Status Bar

另外,要将它放在状态栏上,请查看此链接: 活动监视器状态栏