0

私の目標は、中央のセルに全文を表示し、他のセルに切り捨てられたテキストを表示することですが、中央のセルを変更しても、このスタイルは変更されません (中央の 1 つの全文と他のセルが切り捨てられることを意味します)。

プリセット: セルにラベルが付いた水平スクロール コレクション ビューでの無限スクロール。

3 つのセルがあり、[1D]---[1 日]---[1D] のように見えるはずです。

4

1 に答える 1

0

次のようにして、中央のセルを見つけることができます。

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
    let cell:UICollectionViewCell = collectionView.dequeueReusableCell(withReuseIdentifier: "CELL_ID", for: indexPath)

    let center = self.view.convert(collectionView.center, to: collectionView)
    let index = collectionView.indexPathForItem(at: center)

    if (indexPath == index) {
        // truncated text
    } else {
        // don't truncated text
    }

    return cell
}
于 2018-06-13T11:07:51.187 に答える