Reputation: 1396
I have a UICollectionView
and I try to select all or clear all item/cell after a UIButton
is tapped.
How can I do that like picture?
Upvotes: 0
Views: 140
Reputation: 6223
For that you have to manage one array for selection or you if you are using model then you can add one more field for selection property.
@IBAction func selectAll(_ sender: UIButton) {
// Set Whole Array to 1 and reload collection view.
}
@IBAction func clearAll(_ sender: UIButton) {
//Set Whole array to 0 and reload collection View
}
// In collectionView method Check selection condition and Display Check mark.
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
// If Array value is 1 at indexPath.row then set Checked view otherwise Unchecked view.
}
Upvotes: 1