回答編集履歴
2
変更
test
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
最近はライブラリを使用する事が多いですが、以前は簡単なクラスを定義して利用していました。
|
2
2
|
|
3
3
|
見た目にこだわらないのあれば用途的には十分だと思います。
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
※コメント頂いた通りSingletonにする必要がなかったのでコードを修正しました。
|
4
8
|
|
5
9
|
|
6
10
|
|
@@ -18,23 +22,13 @@
|
|
18
22
|
|
19
23
|
|
20
24
|
|
21
|
-
static
|
25
|
+
static var Indicator = UIActivityIndicatorView(activityIndicatorStyle: .WhiteLarge)
|
22
26
|
|
23
|
-
|
27
|
+
static let baseView = UIView()
|
24
|
-
|
25
|
-
return instance
|
26
|
-
|
27
|
-
}()
|
28
28
|
|
29
29
|
|
30
30
|
|
31
|
-
var Indicator = UIActivityIndicatorView(activityIndicatorStyle: .WhiteLarge)
|
32
|
-
|
33
|
-
var baseView = UIView()
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
func generateBaseView(parentView: UIView) {
|
31
|
+
static func generateBaseView(parentView: UIView) {
|
38
32
|
|
39
33
|
|
40
34
|
|
@@ -56,9 +50,9 @@
|
|
56
50
|
|
57
51
|
|
58
52
|
|
59
|
-
func showIndicator(parentView: UIView?) {
|
53
|
+
static func showIndicator(parentView: UIView?) {
|
60
54
|
|
61
|
-
|
55
|
+
|
62
56
|
|
63
57
|
if let parentView = parentView {
|
64
58
|
|
@@ -72,7 +66,7 @@
|
|
72
66
|
|
73
67
|
|
74
68
|
|
75
|
-
func hideIndicator() {
|
69
|
+
static func hideIndicator() {
|
76
70
|
|
77
71
|
baseView.removeFromSuperview()
|
78
72
|
|
@@ -88,19 +82,19 @@
|
|
88
82
|
|
89
83
|
// 呼び出すところ(NavigationControllerの場合)
|
90
84
|
|
91
|
-
IndicatorView.sh
|
85
|
+
IndicatorView.showIndicator(navigationController?.view)
|
92
86
|
|
93
87
|
|
94
88
|
|
95
89
|
// 呼び出すところ(ViewControllerの場合)
|
96
90
|
|
97
|
-
IndicatorView.sh
|
91
|
+
IndicatorView.showIndicator(view)
|
98
92
|
|
99
93
|
|
100
94
|
|
101
95
|
// 消す時
|
102
96
|
|
103
|
-
IndicatorView.
|
97
|
+
IndicatorView.hideIndicator()
|
104
98
|
|
105
99
|
```
|
106
100
|
|
1
追記
test
CHANGED
@@ -103,3 +103,7 @@
|
|
103
103
|
IndicatorView.sharedInstance.hideIndicator()
|
104
104
|
|
105
105
|
```
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
![image](3cb53758223f8f27081dc8e06a374250.png)
|