iOS UICollectionView 实现多选及取消

来源:互联网 发布:2017软件设计师 编辑:程序博客网 时间:2024/06/06 12:32
1、首先需要实现这个方法

_resourceCollectionView.allowsMultipleSelection =YES;//实现多选必须实现这个方法2、


2、然后实现以下两个方法即可

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath

{

    ResourceCollectionViewCell *cell = (ResourceCollectionViewCell *)[collectionViewcellForItemAtIndexPath:indexPath];

    cell.label.backgroundColor =ColorFrom16(0xFFEFE5);

}


- (void)collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath

{

    ResourceCollectionViewCell *cell = (ResourceCollectionViewCell *)[collectionViewcellForItemAtIndexPath:indexPath];

    cell.label.backgroundColor =ColorWhite;

    

}


原创粉丝点击