質問編集履歴

3

Headerでした

2018/10/23 07:26

投稿

oyasumi
oyasumi

スコア13

test CHANGED
File without changes
test CHANGED
@@ -44,13 +44,13 @@
44
44
 
45
45
 
46
46
 
47
- ### cell(xib)
47
+ ### header(xib)
48
48
 
49
49
  ![イメージ説明](08b4f03116a6c22d632efbdb88a606b2.png)
50
50
 
51
51
 
52
52
 
53
- ### cell(swiftファイル)
53
+ ### header(swiftファイル)
54
54
 
55
55
  ```Swift
56
56
 

2

cell swift ファイル

2018/10/23 07:26

投稿

oyasumi
oyasumi

スコア13

test CHANGED
File without changes
test CHANGED
@@ -47,3 +47,117 @@
47
47
  ### cell(xib)
48
48
 
49
49
  ![イメージ説明](08b4f03116a6c22d632efbdb88a606b2.png)
50
+
51
+
52
+
53
+ ### cell(swiftファイル)
54
+
55
+ ```Swift
56
+
57
+ import Foundation
58
+
59
+ import UIKit
60
+
61
+ //TODO: トグルのIconはスクショで代用してるだけなので変更が必要
62
+
63
+
64
+
65
+ class QAHeaderView: CustomViewBase{
66
+
67
+
68
+
69
+ @IBOutlet weak var questionLabel: UILabel!
70
+
71
+ @IBOutlet weak var toggleImage: UIImageView!
72
+
73
+ // @IBOutlet weak var topAllgnmentConstraint: NSLayoutConstraint!
74
+
75
+ // @IBOutlet weak var bottomAllgnmentConstraint: NSLayoutConstraint!
76
+
77
+ @IBOutlet weak var borderHeightConstraint: NSLayoutConstraint!
78
+
79
+
80
+
81
+ // MARK: - Initializer
82
+
83
+ required init(frame: CGRect) {
84
+
85
+ super.init(frame: frame)
86
+
87
+ setupEventHeaderView()
88
+
89
+ }
90
+
91
+ let parentsVC = QAViewController()
92
+
93
+ required init?(coder aDecoder: NSCoder) {
94
+
95
+ super.init(coder: aDecoder)
96
+
97
+ setupEventHeaderView()
98
+
99
+ }
100
+
101
+
102
+
103
+ // MARK: - Function
104
+
105
+ //ここでlabelにtext代入
106
+
107
+ func setHeader(_ qa: QA) {
108
+
109
+ // topAllgnmentConstraint.constant = parentsVC.screenSize.height * 0.0284
110
+
111
+ // bottomAllgnmentConstraint.constant = parentsVC.screenSize.height * 0.0284
112
+
113
+ questionLabel.text = qa.question
114
+
115
+ }
116
+
117
+ //ここでAnswerが開かれてるか判断
118
+
119
+ //アイコンは開閉に合わせて角度を変更
120
+
121
+ func shouldExtended(_ result: Bool) {
122
+
123
+ var rotationEnd: CGFloat
124
+
125
+ if result {
126
+
127
+ rotationEnd = 180.0
128
+
129
+ borderHeightConstraint.constant = 0
130
+
131
+ } else {
132
+
133
+ rotationEnd = 0.0
134
+
135
+ borderHeightConstraint.constant = 1
136
+
137
+ }
138
+
139
+ UIView.animate(withDuration: 0.16, animations: {
140
+
141
+ self.toggleImage.transform = CGAffineTransform(rotationAngle: (rotationEnd * CGFloat(Double.pi)) / 180.0)
142
+
143
+ })
144
+
145
+ }
146
+
147
+
148
+
149
+ // MARK: - Private Function
150
+
151
+ private func setupEventHeaderView() {
152
+
153
+ toggleImage.backgroundColor = UIColor.white
154
+
155
+ toggleImage.transform = CGAffineTransform(rotationAngle: (0.0 * CGFloat(Double.pi)) / 180.0)
156
+
157
+ }
158
+
159
+ }
160
+
161
+
162
+
163
+ ```

1

cell xib制約

2018/10/23 05:53

投稿

oyasumi
oyasumi

スコア13

test CHANGED
File without changes
test CHANGED
@@ -39,3 +39,11 @@
39
39
  XCode 9.4.1
40
40
 
41
41
  Swift 4.1.2
42
+
43
+
44
+
45
+
46
+
47
+ ### cell(xib)
48
+
49
+ ![イメージ説明](08b4f03116a6c22d632efbdb88a606b2.png)