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

回答編集履歴

2

Color

2018/03/01 03:46

投稿

fuzzball
fuzzball

スコア16733

answer CHANGED
@@ -14,6 +14,6 @@
14
14
 
15
15
  ```swift
16
16
  if let cell = collectionView.cellForItem(at: indexPath) {
17
- cell.contentView.background = .red
17
+ cell.contentView.backgroundColor = .red
18
18
  }
19
19
  ```

1

cellForItem(at:)

2018/03/01 03:46

投稿

fuzzball
fuzzball

スコア16733

answer CHANGED
@@ -6,4 +6,14 @@
6
6
 
7
7
  で色は変わると思います。
8
8
 
9
- あとは、「セルの再利用」について調べて下さい。
9
+ あとは、「セルの再利用」について調べて下さい。
10
+
11
+ # セルの取得
12
+
13
+ セルの取得方法が間違っています。
14
+
15
+ ```swift
16
+ if let cell = collectionView.cellForItem(at: indexPath) {
17
+ cell.contentView.background = .red
18
+ }
19
+ ```