回答編集履歴
1
indexPathForItem(at:)
test
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
スクロールしない前提なので直接セルの背景色を変えています。
|
2
|
-
|
3
|
-
100個くらいなら大丈夫そうですが、数が増えると厳しいですね。
|
4
2
|
|
5
3
|
|
6
4
|
|
@@ -8,22 +6,10 @@
|
|
8
6
|
|
9
7
|
let point = touchEvent.location(in: self)
|
10
8
|
|
11
|
-
f
|
9
|
+
if let indexPath = self.indexPathForItem(at: point), let cell = self.cellForItem(at: indexPath) {
|
12
10
|
|
13
|
-
if cell.frame.contains(point) {
|
14
|
-
|
15
|
-
|
11
|
+
cell.backgroundColor = .green
|
16
|
-
|
17
|
-
break
|
18
|
-
|
19
|
-
}
|
20
12
|
|
21
13
|
}
|
22
14
|
|
23
15
|
```
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
スクロールしないならCollectionViewを使わずに自分でViewを管理して、`X座標 / View幅`と`Y座標 / View高`で、計算によってViewを特定できるので、数が増えても速度低下しないと思います。
|
28
|
-
|
29
|
-
CollectionViewを使う必要がありますか?
|