質問編集履歴

1

詳しく載せました。おかしな点が多々あると思いますがよろしくお願いします。

2018/11/02 13:57

投稿

imazai
imazai

スコア16

test CHANGED
@@ -1 +1 @@
1
- swift ボタン
1
+ swift ボタン
test CHANGED
@@ -1,5 +1,135 @@
1
- ボタン1.2.3があって、3あらかじめけしてます。
1
+ ボタン12345を用意いしました。ボタン5非表示にしてます。
2
2
 
3
- 1をタップし2をタップしたら3が表示されるようにしたいです。
3
+ なぜ非表示かというと、ボタン1234のうち1、2をタップ たとき、1、3をタップした時1、4を、2、3を......というように二つのボタンをタップした時(バックグラウンドの色が青になった時)にボタン5を表示させたからです。
4
4
 
5
+ まずボタン5を非表示にする場合
6
+
7
+ `button5.isHidden = true`のコードの場所はここでいいのでしょうか?
8
+
9
+ あと、私が実行したいことの解釈はbutton1,2のバックグラウンドカラーが青になった時button5を表示。でいいんでしょうか?
10
+
11
+ だとしても各ボタンのActionの続きに?
12
+
13
+ outletの所に?と基礎的なことがわかっていないため、悩みに悩んでいます。
14
+
5
- どなたか解答よろしくお願いします
15
+ 解答よろしくお願いします
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+ ```
26
+
27
+
28
+
29
+ import UIKit
30
+
31
+
32
+
33
+ class kamotsuViewController: UIViewController {
34
+
35
+
36
+
37
+ @IBOutlet weak var button1: UIButton!
38
+
39
+ @IBOutlet weak var button2: UIButton!
40
+
41
+ @IBOutlet weak var button3: UIButton!
42
+
43
+ @IBOutlet weak var button4: UIButton!
44
+
45
+ @IBOutlet weak var button5: UIButton!
46
+
47
+ override func viewDidLoad() {
48
+
49
+ super.viewDidLoad()
50
+
51
+ button5.isHidden = true
52
+
53
+
54
+
55
+ }
56
+
57
+ @IBAction func button1(_ sender: UIButton) {
58
+
59
+ if button1.backgroundColor == nil{
60
+
61
+ button1.backgroundColor = UIColor.blue
62
+
63
+ }
64
+
65
+ else if button1.backgroundColor == UIColor.blue{
66
+
67
+ button1.backgroundColor = nil
68
+
69
+ }
70
+
71
+
72
+
73
+
74
+
75
+ }
76
+
77
+
78
+
79
+ @IBAction func button2(_ sender: UIButton) {
80
+
81
+ if button2.backgroundColor == nil{
82
+
83
+ button2.backgroundColor = UIColor.blue
84
+
85
+ }
86
+
87
+ else if button2.backgroundColor == UIColor.blue{
88
+
89
+ button2.backgroundColor = nil
90
+
91
+ }
92
+
93
+
94
+
95
+
96
+
97
+ }
98
+
99
+ @IBAction func button3(_ sender: UIButton) {
100
+
101
+ if button3.backgroundColor == nil{
102
+
103
+ button3.backgroundColor = UIColor.blue
104
+
105
+ }
106
+
107
+ else if button3.backgroundColor == UIColor.blue{
108
+
109
+ button3.backgroundColor = nil
110
+
111
+ }
112
+
113
+
114
+
115
+ }
116
+
117
+ @IBAction func button4(_ sender: UIButton) {
118
+
119
+ if button4.backgroundColor == nil{
120
+
121
+ button4.backgroundColor = UIColor.blue
122
+
123
+ }
124
+
125
+ else if button4.backgroundColor == UIColor.blue{
126
+
127
+ button4.backgroundColor = nil
128
+
129
+ }
130
+
131
+
132
+
133
+ }
134
+
135
+ ```