質問するログイン新規登録

質問編集履歴

2

追記

2021/01/23 01:51

投稿

momokoko
momokoko

スコア38

title CHANGED
File without changes
body CHANGED
@@ -20,6 +20,7 @@
20
20
 
21
21
  // MARK: - Lifecycle
22
22
  override init(frame: CGRect) {
23
+      super.init(frame:frame)
23
24
  addSubview(followersLabel)
24
25
  followersLabel.anchor(top:view.bottomAnchor,left: leftAnchor,
25
26
  right: rightAnchor,paddingTop: 16,

1

修正

2021/01/23 01:51

投稿

momokoko
momokoko

スコア38

title CHANGED
File without changes
body CHANGED
@@ -2,13 +2,51 @@
2
2
  なぜエラーが解消できるのか知りたいです。
3
3
 
4
4
  ```ここに言語を入力
5
+
6
+ import UIKit
7
+
8
+ class ProfileHeader: UICollectionReusableView {
9
+
10
+
11
+ // MARK: - Properties
5
- private var followersLabel: UILabel = {
12
+ private lazy var followersLabel: UILabel = {
6
13
  let label = UILabel()
7
14
  label.numberOfLines = 0
8
15
  label.textAlignment = .center
9
16
  label.attributedText = attributedStatText(value: 2, label: "followers")
10
17
  return label
11
18
  }()
19
+
20
+
21
+ // MARK: - Lifecycle
22
+ override init(frame: CGRect) {
23
+ addSubview(followersLabel)
24
+ followersLabel.anchor(top:view.bottomAnchor,left: leftAnchor,
25
+ right: rightAnchor,paddingTop: 16,
26
+ paddingLeft: 24,paddingRight: 24)
27
+ }
28
+
29
+    ④
30
+ // MARK: - Helpers
31
+ required init?(coder: NSCoder) {
32
+ fatalError("init(coder:) has not been implemented")
33
+ }
34
+
35
+   ⑤
36
+ // MARK: - Actions
37
+ @objc func handleChangeProfileImage() {
38
+ print("ボタンがタップされました")
39
+ }
40
+
41
+    ⑥
42
+ // MARK: - Helpers
43
+ func attributedStatText(value: Int,label: String) -> NSAttributedString {
44
+ let attributedText = NSMutableAttributedString(string: "(value)\n", attributes: [.font: UIFont.boldSystemFont(ofSize: 14)])
45
+ attributedText.append(NSAttributedString(string: label, attributes: [.font: UIFont.systemFont(ofSize: 14), .foregroundColor: UIColor.lightGray ]))
46
+ return attributedText
47
+ }
48
+ }
49
+
12
50
  ```
13
51
 
14
52
  エラー文