2025年UICollectionView的单选

UICollectionView的单选选定 void collectionVi UICollection collectionVi didSelectIte NSIndexPath indexPath JFCollection cell JFCollection collectionVi

//点击选定

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

{

JFCollectionViewCell *cell = (JFCollectionViewCell *)[collectionView cellForItemAtIndexPath:indexPath];

cell.backgroundColor=[UIColor colorWithRed:27/255.0 green:166/255.0 blue:152/255.0 alpha:1];

cell.topLabel.textColor=[UIColor whiteColor];

cell.bottomLabel.textColor=[UIColor whiteColor];

NSLog(@”第%ld区,第%ld个“,(long)indexPath.section,(long)indexPath.row);

}

//取消选定

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

JFCollectionViewCell *cell = (JFCollectionViewCell *)[collectionView cellForItemAtIndexPath:indexPath];

cell.backgroundColor=[UIColor whiteColor];

cell.topLabel.textColor=[UIColor colorWithRed:27/255.0 green:166/255.0 blue:152/255.0 alpha:1];

cell.bottomLabel.textColor=[UIColor blackColor];

NSLog(@”1第%ld区,1第%ld个“,(long)indexPath.section,(long)indexPath.row);

}

编程小号
上一篇 2025-04-14 18:57
下一篇 2025-03-20 16:01

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/hz/134312.html