didSelectItemAtIndexPath에서 내 사용자 지정 컬렉션보기 셀의 배경색을 변경하고 싶습니다. 내 구현은 다음과 같습니다.사용자 지정 CollectionViewCell의 배경색을 변경하는 방법?
- (void)collectionView:(UICollectionView *)collectionView
didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
RadioCollectionViewCell* cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"RadioCollectionViewCell" forIndexPath:indexPath];
[cell setData:self.contentModel andIndexPath:indexPath];
cell.lblChoice.backgroundColor = ColorFromRGB(COLOR_GREEN);
}
여기 RadioCollectionViewCell.h
#import <UIKit/UIKit.h>
@interface RadioCollectionViewCell : UICollectionViewCell
@property (weak, nonatomic) IBOutlet UILabel *lblChoice;
- (void)setData:(ContentModel *)contentModel andIndexPath:(NSIndexPath *)indexPath;
+ (RadioCollectionViewCell *)loadFromNib;
@end
내 구현하지만 배경 색상은 변경되지 않았다. 샘플 솔루션을 확인할 때 배경색을 UICollectionViewCell
으로 변경하는 중입니다. 관습이 아닌. 나는 그걸 CustomAnnotationView
에서 할 수 있는지 알고 싶습니까?
코드를 추가하십시오. –