【发布时间】:2017-12-21 01:50:43
【问题描述】:
我想更改 didSelectItemAtIndexPath 中自定义集合视图单元格的背景颜色。 这是我的实现。
- (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 中这样做吗?
【问题讨论】:
-
请提供更多代码。
标签: ios objective-c uicollectionviewcell