Network Activity Indicatorとは?

Status Barに通信中を表すグルグルを表示する機能です。
Network Activity Indicatorの現状
- iOS13で
Deprecatedになっている。 - Touch ID機種でしか表示されない。
iOS18で表示されなくなった模様
| iOS | |||||
|---|---|---|---|---|---|
| Device | 18.1 | 18.0 | 17.5 | 16.4 | 15.4 |
| iPhone SE 3rd | 非表示 | 非表示 | 表示 | 表示 | 表示 |
| iPhone SE 2nd | 非表示 | 非表示 | 表示 | 表示 | 表示 |
| iPhone SE 1st | − | − | − | − | 表示 |
| iPhone 8 | − | − | − | 表示 | 表示 |
| iPhone 7 | − | − | − | − | 表示 |
| iPhone 6s | − | − | − | − | 表示 |
| iOS 15.4 | iOS 18.0 |
|---|---|
![]() |
![]() |
「それで、あんたはどうするの?」
Network Activity Indicatorは...
- 絶滅する運命なので使わなくても大丈夫だと思います。
- 既に使っているプロジェクトでは削除する提案をするのも良いと思います。
- 通信中を表現するUIは他にも選択肢がありますよね。
- ProgressView
- Reducted
- など
ソースコード
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let networkSwitch = UISwitch()
networkSwitch.translatesAutoresizingMaskIntoConstraints = false
networkSwitch.addAction(.init{ _ in
UIApplication.shared.isNetworkActivityIndicatorVisible = networkSwitch.isOn
}, for: .valueChanged)
let statusLabel = UILabel()
statusLabel.translatesAutoresizingMaskIntoConstraints = false
statusLabel.text = "Network Activity Indicator"
statusLabel.textAlignment = .left
let stackView = UIStackView(arrangedSubviews: [statusLabel, networkSwitch])
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .horizontal
stackView.alignment = .center
stackView.spacing = 16
self.view.addSubview(stackView)
NSLayoutConstraint.activate([
stackView.leadingAnchor.constraint(equalTo: self.view.leadingAnchor, constant: 16),
stackView.topAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.topAnchor, constant: 16)
])
}
}
検証環境
Xcode 15.2, 16.0, 16.1

