UICollectionView 相似UIButton點擊變灰,鬆開恢復

//設置點擊高亮和非高亮效果!it

- (BOOL)collectionView:(UICollectionView *)collectionView shouldHighlightItemAtIndexPath:(NSIndexPath *)indexPath{io

 

    NSLog(@"shouldHighlightItemAtIndexPath");di

    return YES;co

}return

 

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

    

    NSLog(@"didHighlightItemAtIndexPath");index

    UICollectionViewCell *cell = [collectionView cellForItemAtIndexPath:indexPath];

    [cell setBackgroundColor:UIColorFromRGB(0xC9C9C9)];

}

 

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

    

    NSLog(@"didUnhighlightItemAtIndexPath");

    

    UICollectionViewCell *cell = [collectionView cellForItemAtIndexPath:indexPath];

    [cell setBackgroundColor:[UIColor whiteColor]];

}

相關文章
相關標籤/搜索