func createCollectionView() {
let layout = UICollectionViewFlowLayout()
let size: CGSize = UIScreen.main.bounds.size
let w: Int = (size.width - 70) / 4
layout.itemSize = CGSize(width: CGFloat(w), height: 80)
layout.minimumInteritemSpacing = 10
layout.minimumLineSpacing = 20
layout.sectionInset = UIEdgeInsetsMake(20, 20, 20, 20)
collectionView = UICollectionView(frame: CGRect(x: 0, y: 0, width: size.width, height: size.height), collectionViewLayout: layout)
collectionView.backgroundColor = UIColor(red: 236 / 255.0, green: 235 / 255.0, blue: 241 / 255.0, alpha: 1)
collectionView.delegate = self
collectionView.dataSource = self
view.addSubview(collectionView)
collectionView.register(UICollectionViewCell.self, forCellWithReuseIdentifier: “cell”)
collectionView.register(CustomerCollectionViewCell.self, forCellWithReuseIdentifier: “CustomerCollectionViewCell”)
}
collectionview
最新推荐文章于 2020-01-07 11:29:37 发布