0

コレクション ビューがあり、すべてのセル間の間隔をプログラムで計算したいのですが、その方法がわかりません。

では、UICollectionViewFlowLayout を使用して UICollectionView 内の UICollectionViewCells 間のセル間の間隔を計算するにはどうすればよいですか?

4

1 に答える 1

1

以下は、コレクション ビューでカスタム セル間隔を設定する方法です。拡張機能を作成する必要があります。

extension ViewController : UICollectionViewDelegateFlowLayout {

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {

    return //whatever you want//

}

拡張子に続く「ViewController」がビューコントローラーの名前であることを確認してください。

于 2016-10-15T17:02:18.700 に答える