Recusiwe
Recusiwe

Reputation: 898

Swift 3 manipulating UICollectionViewCell size?

I'm struggling with manipulating my UICollectionViewCell sizes, since it seem the function is deprecated, same goes for spacing. I've tried with this one:

func collectionView(collectionView: UICollectionView,
                        layout collectionViewLayout: UICollectionViewLayout,
                        sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
        return CGSize(width: 150, height: 150)
    }

Which function am I supposed to use in Swift 3?

Upvotes: 0

Views: 5602

Answers (2)

serhat sezer
serhat sezer

Reputation: 1344

You can use below delegate method.

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
        
        return CGSize(width: 100, height: 100)
    }

Upvotes: 0

fzh
fzh

Reputation: 688

you can try this code in swift3

override var collectionViewContentSize: CGSize {
    return CGSize(width: 150, height: 150)
}

Upvotes: 4

Related Questions