回答編集履歴
5
修正
test
CHANGED
@@ -94,7 +94,9 @@
|
|
94
94
|
|
95
95
|
statedText.toggle()
|
96
96
|
|
97
|
-
button.text = statedText.text
|
97
|
+
// button.text = statedText.text
|
98
|
+
|
99
|
+
button.setTitle(statedText.text,for: UIControlState.normal)
|
98
100
|
|
99
101
|
}
|
100
102
|
|
4
label -> Button
test
CHANGED
@@ -152,7 +152,7 @@
|
|
152
152
|
|
153
153
|
|
154
154
|
|
155
|
-
return Stated
|
155
|
+
return StatedButton(button: button, onText: "オンの時のテキスト", offText: "オフの時のテキスト")
|
156
156
|
|
157
157
|
}
|
158
158
|
|
3
label -> Button
test
CHANGED
@@ -180,7 +180,7 @@
|
|
180
180
|
|
181
181
|
buttons
|
182
182
|
|
183
|
-
.filter { statedButton in sender == statedButton.
|
183
|
+
.filter { statedButton in sender == statedButton.button }
|
184
184
|
|
185
185
|
.first
|
186
186
|
|
2
label -> Button
test
CHANGED
@@ -174,7 +174,7 @@
|
|
174
174
|
|
175
175
|
|
176
176
|
|
177
|
-
@objc func buttonTapped(_ sender: UI
|
177
|
+
@objc func buttonTapped(_ sender: UIButton) {
|
178
178
|
|
179
179
|
|
180
180
|
|
1
label -> Button
test
CHANGED
@@ -80,11 +80,11 @@
|
|
80
80
|
|
81
81
|
|
82
82
|
|
83
|
-
class Stated
|
83
|
+
class StatedButton {
|
84
84
|
|
85
85
|
private var statedText: StatedText
|
86
86
|
|
87
|
-
let
|
87
|
+
let button: UIButton
|
88
88
|
|
89
89
|
|
90
90
|
|
@@ -94,17 +94,17 @@
|
|
94
94
|
|
95
95
|
statedText.toggle()
|
96
96
|
|
97
|
-
|
97
|
+
button.text = statedText.text
|
98
98
|
|
99
99
|
}
|
100
100
|
|
101
101
|
|
102
102
|
|
103
|
-
init(
|
103
|
+
init(button: UIButton, onText: String, offText: String) {
|
104
104
|
|
105
105
|
|
106
106
|
|
107
|
-
self.
|
107
|
+
self.button= button
|
108
108
|
|
109
109
|
self.statedText = StatedText(onText: onText, offText: offText)
|
110
110
|
|
@@ -124,7 +124,7 @@
|
|
124
124
|
|
125
125
|
...
|
126
126
|
|
127
|
-
var
|
127
|
+
var buttons: [StatedButton] = []
|
128
128
|
|
129
129
|
|
130
130
|
|
@@ -142,9 +142,9 @@
|
|
142
142
|
|
143
143
|
...
|
144
144
|
|
145
|
-
|
145
|
+
buttons = sam1.sam1.map { sample in
|
146
146
|
|
147
|
-
let
|
147
|
+
let button = UIButton()
|
148
148
|
|
149
149
|
...
|
150
150
|
|
@@ -178,13 +178,13 @@
|
|
178
178
|
|
179
179
|
|
180
180
|
|
181
|
-
|
181
|
+
buttons
|
182
182
|
|
183
|
-
.filter { stated
|
183
|
+
.filter { statedButton in sender == statedButton.label }
|
184
184
|
|
185
185
|
.first
|
186
186
|
|
187
|
-
.map { stated
|
187
|
+
.map { statedButton in statedButton.toggle() }
|
188
188
|
|
189
189
|
}
|
190
190
|
|