How to change cell color of cell when selected?

How do I change the cell background color once its been tapped or selected???

	func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
		return totalSquares.count
	}

	 
	func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
		let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "calCell", for: indexPath) as! CalendarCell

		cell.dayOfMonth.text = totalSquares[indexPath.item]
		
		
		
		return cell
	}

https://developer.apple.com/documentation/uikit/uicollectionviewcell/1620130-isselected

Terms of Service

Privacy Policy

Cookie Policy