1.collectionView
[_collectionView registerClass:[DIANJINGSignCollectionViewCell class]
forCellWithReuseIdentifier:@"DIANJINGSignCollectionViewCell"];
[_collectionView registerNib:[UINib nibWithNibName:@"DIANJINGSignCollectionViewCell"
bundle:nil] forCellWithReuseIdentifier:@"DIANJINGSignCollectionViewCell"];
_collectionView.backgroundColor=[UIColor clearColor];
_collectionView.dataSource=self;
_collectionView.delegate=self;
_collectionView.delaysContentTouches=NO;
[_collectionView layoutIfNeeded];
#pragma mark -UICollectionViewDataSource
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
return 1;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
return [_titleArray count];
}
-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section{
return 14;
}
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
return [DIANJINGSignCollectionViewCell getSize];
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
DIANJINGSignCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"DIANJINGSignCollectionViewCell" forIndexPath:indexPath];
NSString *string=[_titleArray objectAtIndex:indexPath.item];
if(indexPath.item < _signDays){//已签到样式
[cell setContentWithString:string type:1];
}
else{//未签到样式
[cell setContentWithString:string type:0];
}
return cell;
}
2.tableView
[_tableView registerNib:[UINib nibWithNibName:@"DIANJINGSignTableViewCell" bundle:nil] forCellReuseIdentifier:@"DIANJINGSignTableViewCell"];
_tableView.dataSource = self;
_tableView.delegate = self;
_tableView.backgroundColor = UIColor.clearColor;
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_tableView.tableFooterView = [[UIView alloc] init];
_tableView.delaysContentTouches = NO;
[_tableView fa_setNoDataViewWithText:@"暂无任务"];
[self.tableView fa_readyForDisplay];
#pragma mark -UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 3;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return [DIANJINGSignTableViewCell getHeight];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
NSString *identifier=@"DIANJINGSignTableViewCell";
DIANJINGSignTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:identifier];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}