小编Jef*_*eff的帖子

Swift如何取消选择Collection Cell

TenViewController代码:

class TenViewController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource {
        var selectedCell: UICollectionViewCell!
        var arrayLocation = ["aaa", "bbb", "ccc", "ddd", "eee"]
        var myCollectionView: UICollectionView!
        func numberOfSections(in collectionView: UICollectionView) -> Int
            {
                return 1
            }
            func collectionView(_ collectionView: UICollectionView,numberOfItemsInSection section: Int) -> Int
            {
                return arrayLocation.count
            }
Run Code Online (Sandbox Code Playgroud)

集合代表

            func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
                let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath) as! MyCollectionViewCell
                cell.backgroundColor = UIColor.white
                cell.titleLabel?.text = arrayLocation[indexPath.row]
                cell.titleLabel.font = UIFont.systemFont(ofSize: 24)
                return cell
            }
            // check cell and …
Run Code Online (Sandbox Code Playgroud)

uicollectionview uicollectionviewcell swift swift3

6
推荐指数
2
解决办法
6063
查看次数