一般UICollectionView点击后会显示默认的透明色,希望修改为特定的颜色,最终发现是设置背景色的view设置错了,应该是:[cell.contentView setBackgroundColor:[UIColor redColor]];
具体代码如下:
- (BOOL)collectionView:(UICollectionView *)collectionView shouldHighlightItemAtIndexPath:(NSIndexPath *)indexPath
{
return YES;
}
- (void)collectionView:(UICollectionView *)collectionView didHighlightItemAtIndexPath:(NSIndexPath *)indexPath{
UICollectionViewCell* cell = [collectionView cellForItemAtIndexPath:indexPath];
//设置(Highlight)高亮下的颜色
[cell.contentView setBackgroundColor:[UIColor redColor]];
}
- (