質問編集履歴
1
詳しく載せました。おかしな点が多々あると思いますがよろしくお願いします。
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
swift ボタン
|
1
|
+
swift ボタン5つ
|
body
CHANGED
@@ -1,3 +1,68 @@
|
|
1
|
-
ボタン1.2.3があって、3はあらかじめけしてます。
|
2
|
-
|
1
|
+
ボタン12345を用意いしました。ボタン5は非表示にしています。
|
2
|
+
なぜ非表示かというと、ボタン1234のうち1、2をタップ したとき、1、3をタップした時1、4を、2、3を......というように二つのボタンをタップした時(バックグラウンドの色が青になった時)にボタン5を表示させたいからです。
|
3
|
+
まずボタン5を非表示にする場合
|
4
|
+
`button5.isHidden = true`のコードの場所はここでいいのでしょうか?
|
5
|
+
あと、私が実行したいことの解釈はbutton1,2のバックグラウンドカラーが青になった時button5を表示。でいいんでしょうか?
|
6
|
+
だとしても各ボタンのActionの続きに?
|
7
|
+
outletの所に?と基礎的なことがわかっていないため、悩みに悩んでいます。
|
3
|
-
|
8
|
+
解答よろしくお願いします!
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
```
|
14
|
+
|
15
|
+
import UIKit
|
16
|
+
|
17
|
+
class kamotsuViewController: UIViewController {
|
18
|
+
|
19
|
+
@IBOutlet weak var button1: UIButton!
|
20
|
+
@IBOutlet weak var button2: UIButton!
|
21
|
+
@IBOutlet weak var button3: UIButton!
|
22
|
+
@IBOutlet weak var button4: UIButton!
|
23
|
+
@IBOutlet weak var button5: UIButton!
|
24
|
+
override func viewDidLoad() {
|
25
|
+
super.viewDidLoad()
|
26
|
+
button5.isHidden = true
|
27
|
+
|
28
|
+
}
|
29
|
+
@IBAction func button1(_ sender: UIButton) {
|
30
|
+
if button1.backgroundColor == nil{
|
31
|
+
button1.backgroundColor = UIColor.blue
|
32
|
+
}
|
33
|
+
else if button1.backgroundColor == UIColor.blue{
|
34
|
+
button1.backgroundColor = nil
|
35
|
+
}
|
36
|
+
|
37
|
+
|
38
|
+
}
|
39
|
+
|
40
|
+
@IBAction func button2(_ sender: UIButton) {
|
41
|
+
if button2.backgroundColor == nil{
|
42
|
+
button2.backgroundColor = UIColor.blue
|
43
|
+
}
|
44
|
+
else if button2.backgroundColor == UIColor.blue{
|
45
|
+
button2.backgroundColor = nil
|
46
|
+
}
|
47
|
+
|
48
|
+
|
49
|
+
}
|
50
|
+
@IBAction func button3(_ sender: UIButton) {
|
51
|
+
if button3.backgroundColor == nil{
|
52
|
+
button3.backgroundColor = UIColor.blue
|
53
|
+
}
|
54
|
+
else if button3.backgroundColor == UIColor.blue{
|
55
|
+
button3.backgroundColor = nil
|
56
|
+
}
|
57
|
+
|
58
|
+
}
|
59
|
+
@IBAction func button4(_ sender: UIButton) {
|
60
|
+
if button4.backgroundColor == nil{
|
61
|
+
button4.backgroundColor = UIColor.blue
|
62
|
+
}
|
63
|
+
else if button4.backgroundColor == UIColor.blue{
|
64
|
+
button4.backgroundColor = nil
|
65
|
+
}
|
66
|
+
|
67
|
+
}
|
68
|
+
```
|