UICollectionViewCell - element inside a controller (can be a friend entry in whatsapp/messenger)
class FriendCell: UICollectionViewCell { override init(frame: CGRect) { super.init(frame: frame) setupViews() } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } func setupViews() { backgroundColor = UIColor.blue } }
To register UICollectionViewCell to Controller add in viewDidLoad()
collectionView.register(FriendCell.self, forCellWithReuseIdentifier: cellId)
Making UICollectionViewCell to take full row
func collectionView(_ collectionView: UICollectionView, layout collectionviewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { return CGSize(width: view.frame.width, height: 100) }