美文网首页
CollectionView总结 Swift(2019)

CollectionView总结 Swift(2019)

作者: Look2021 | 来源:发表于2019-08-15 10:22 被阅读0次
lazy var collectionView: UICollectionView = {
    
    let collectionLayout = UICollectionViewFlowLayout()
    collectionLayout.itemSize = CGSize(width: 260 / 4, height: 80)~
    collectionLayout.scrollDirection = .horizontal
    collectionLayout.minimumInteritemSpacing = 0;
    collectionLayout.minimumLineSpacing = 0;
    collectionLayout.sectionInset = UIEdgeInsets.init(top: 0, left: 10~, bottom: 0, right: 0)

    let collection = UICollectionView(frame: .zero, collectionViewLayout: collectionLayout)
    collection.delegate = self
    collection.dataSource = self
    collection.showsVerticalScrollIndicator = false
    collection.showsHorizontalScrollIndicator = false
    collection.isScrollEnabled = false
    collection.register(cellWithClass: ImageLabelCollectionViewCell.self)
    collection.backgroundColor = .clear
    
    return collection
}()
extension HomeNotesCell: UICollectionViewDataSource, UICollectionViewDelegate {
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return 6
    }
    
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withClass: StateNumberCollectionViewCell.self, for: indexPath)
        return cell
    }
}

相关文章

网友评论

      本文标题:CollectionView总结 Swift(2019)

      本文链接:https://www.haomeiwen.com/subject/ukdatctx.html