先新建一个View的xib,而后删掉自动生成的View,拖进一个UICollectionCell,再新建一个对应的UIView继承UICollectionCell类。spa
OK,接下来该连outlet的就连。blog
设置delegate和dataSource继承
而后一般咱们都要这样,it
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell{ let cell = collectionView.dequeueReusableCellWithReuseIdentifier("PersonalizedSettingsMovieCell", forIndexPath: indexPath) as PersonalizedSettingsMovieCell return cell }
但仅仅是这样是不行的,找不到 PersonalizedSettingsMovieCell 的 Identifier,因此咱们要io
1.在xib里面设置Cell的Identifier。class
2.UICollectionCell要设置queue
collectionView.registerNib(UINib(nibName: "PersonalizedSettingsMovieCell", bundle: nil), forCellWithReuseIdentifier: "PersonalizedSettingsMovieCell")