首页 > 代码库 > collectionView初始化

collectionView初始化

collectionView初始化时已定要加layout。不然会报错:

UICollectionView must be initialized with a non-nil layout parameter.

        let layout = UICollectionViewFlowLayout()        layout.scrollDirection = .horizontal        layout.minimumInteritemSpacing = 5        layout.itemSize = CGSize(width: 80, height: StoreDetailsViewController.headerHeight)        self.collectionView = UICollectionView(frame: CGRect(x: 0, y: NavigationBarBaseController.barHeight, width: self.view.frame.width, height: StoreDetailsViewController.headerHeight), collectionViewLayout: layout)

 

collectionView初始化