美文网首页
iOS 多选实现选中、取消

iOS 多选实现选中、取消

作者: anny_4243 | 来源:发表于2018-09-21 14:33 被阅读41次

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

-(BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
return YES;
}

  • (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
    {
    UICollectionViewCell * cell = (UICollectionViewCell *)[collectionView cellForItemAtIndexPath:indexPath];
    cell.checkLbl.textColor = 选中颜色;
    }
  • (void)collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath
    {
    UICollectionViewCell * cell = (UICollectionViewCell *)[collectionView cellForItemAtIndexPath:indexPath];
    cell.checkLbl.textColor = 未选中颜色;
    }

相关文章

网友评论

      本文标题:iOS 多选实现选中、取消

      本文链接:https://www.haomeiwen.com/subject/cpwanftx.html