Почему бы просто не добавить кнопку с уникальным идентификатором в категории?
let addButton = Category(id: "UniqueID", name: "+ add")
// append the addButton in category array
self.categories.append(contentsOf: [categoryOne, categoryTwo, categoryThree, addButton])
А затем просто включите Id, а также есть отдельная ячейка для кнопки.
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let category = self.categories[indexPath.row]
// check for category.id == your uniqueID that you have appended above
if category.id == "UniqueID" {
// Make sure you have another collectionViewCell and use its identifier in here
let cell = collectionView.dequeueReusableCell(withReuseIdentifier:AddButtonCell.name, for: indexPath) as! AddButtonCell
// set the label here
cell.label.text = category.name
return cell
} else {
// use your original collectionview cell here.
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: CategoryCollectionViewCell.name, for: indexPath) as! CategoryCollectionViewCell
cell.label.text = category.name
return cell
}
}