extension ServiceProviderProfileViewController : UICollectionViewDelegate, UICollectionViewDataSource { func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return categories.count } func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = categoryCollectionView.dequeueReusableCell(withReuseIdentifier: "CategoryCollectionViewCell", for: indexPath) as! CategoryCollectionViewCell cell.categoryLabel.text = categories[indexPath.row] if indexPath.row == selectedCellIndex { cell.categoryView.layer.borderColor = UIColor.blue.cgColor cell.categoryLabel.textColor = UIColor.blue } else { cell.categoryView.layer.borderColor = UIColor.lightGray.cgColor cell.categoryLabel.textColor = UIColor.gray } return cell } func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { selectedCellIndex = indexPath.row self.categoryCollectionView.reloadData() } }