iOS UICollectionView 實現多選及取消
阿新 • • 發佈:2019-02-17
1、首先需要實現這個方法
:indexPath];
_resourceCollectionView.allowsMultipleSelection = YES;//實現多選必須實現這個方法2、
2、然後實現以下兩個方法即可
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
ResourceCollectionViewCell *cell = (ResourceCollectionViewCell *)[collectionView cellForItemAtIndexPath
cell.label.backgroundColor = ColorFrom16(0xFFEFE5);
}
- (void)collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath
{
ResourceCollectionViewCell *cell = (ResourceCollectionViewCell *)[collectionView cellForItemAtIndexPath:indexPath];
cell.label.backgroundColor = ColorWhite;
}