直接贴代码:
#import "ViewController.h"
@interface MyCollectionViewCell : UICollectionViewCell
/* *< 是否被选中 >* */
@property (assign,nonatomic,getter=isBeSelected) BOOL beSelected;
@end
/* *< @implementation Cell >* */
@implementation MyCollectionViewCell
@synthesize beSelected = _beSelected;
- (BOOL)isBeSelected
{
return _beSelected;
}
- (void)setBeSelected:(BOOL)beSelected
{
_beSelected = beSelected;
self.backgroundColor = _beSelected?[UIColor redColor]:[UIColor whiteColor];
}
@end
#pragma mark - ****< viewController >****
@interface ViewController ()
@property (strong,nonatomic) UICollectionView *collectionView;
@property (strong,nonatomic) NSMutableArray *dataSouceArray;
@end
/* *< @implementation viewController >* */
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
UICollectionV