40 lines
1.3 KiB
Swift
40 lines
1.3 KiB
Swift
//
|
|
// tyepeCollectionViewFlowLayout.swift
|
|
// Funny_sounds
|
|
//
|
|
// Created by 忆海16 on 2024/8/15.
|
|
//
|
|
|
|
import Foundation
|
|
import UIKit
|
|
class tyepeCollectionViewFlowLayout: UICollectionViewFlowLayout {
|
|
override func prepare() {
|
|
super.prepare()
|
|
|
|
guard let collectionView = collectionView else { return }
|
|
|
|
let itemWidth = (collectionView.bounds.width - minimumInteritemSpacing * 4) / 3
|
|
|
|
itemSize = CGSize(width: itemWidth, height: 140) // 设置每个单元格的大小
|
|
minimumLineSpacing = 5 // 设置行间距
|
|
minimumInteritemSpacing = 5 // 设置列间距
|
|
sectionInset = UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 5)
|
|
}
|
|
}
|
|
|
|
|
|
class collectCollectionViewFlowLayout: UICollectionViewFlowLayout {
|
|
override func prepare() {
|
|
super.prepare()
|
|
|
|
guard let collectionView = collectionView else { return }
|
|
|
|
let itemWidth = (collectionView.bounds.width - minimumInteritemSpacing * 4) / 3
|
|
|
|
itemSize = CGSize(width: itemWidth, height: 148) // 设置每个单元格的大小
|
|
minimumLineSpacing = 5 // 设置行间距
|
|
minimumInteritemSpacing = 5 // 设置列间距
|
|
sectionInset = UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 5)
|
|
}
|
|
}
|