美文网首页
UICollectionViewCell的赋值方法

UICollectionViewCell的赋值方法

作者: eb7a9dac29d0 | 来源:发表于2017-08-10 10:58 被阅读0次

/*

if (indexPath.row < self.firsrtDay ) {

_startDate = @"0";

_startDate = [NSString stringWithFormat:@"%ld",self.lastMonthDays - self.firsrtDay + 1];

//这个月第一天之前的那些cell

[cell.CalendarDateLabel setText:nil];

[cell.CalendarDateLabel setBackgroundColor:[UIColor clearColor]];

[cell setBackgroundColor:[UIColor clearColor]];

[cell.CalendarDateLabel setTextColor:[UIColor clearColor]];

[cell.CalendarDateLabel setText:[NSString stringWithFormat:@"%ld",self.lastMonthDays - self.firsrtDay + indexPath.row+ 1]];

}

else if (indexPath.row < self.firsrtDay + self.days){

if (self.textOrBack == 1) {

[cell setBackgroundColor:[UIColor whiteColor]];

[cell.CalendarDateLabel setBackgroundColor:[UIColor whiteColor]];

[cell.CalendarDateLabel setTextColor:[UIColor redColor]];

}

else if (self.textOrBack == 2){

[cell setBackgroundColor:[UIColor redColor]];

[cell.CalendarDateLabel setBackgroundColor:[UIColor whiteColor]];

[cell.CalendarDateLabel setTextColor:[UIColor blackColor]];

}

else if (self.textOrBack == 3){

[cell setBackgroundColor:[UIColor whiteColor]];

[cell.CalendarDateLabel setBackgroundColor:[UIColor redColor]];

[cell.CalendarDateLabel setTextColor:[UIColor blackColor]];

}

else{

[cell setBackgroundColor:[UIColor colorWithHex:@"#ffffff"]];

[cell.CalendarDateLabel setBackgroundColor:[UIColor colorWithHex:@"#ffffff"]];

[cell.CalendarDateLabel setTextColor:[UIColor blackColor]];

}

//重载方法1有数据的日期

if ([self.dataArr count] > 0) {

NSString * date = [ConvertDate ConvertDateWithYear:self.yearsNum months:self.monthsNum day:indexPath.row - self.firsrtDay+1] ;

for (NSDictionary * time in self.dataArr) {

if ([date isEqualToString:time[self.key]]){

[cell setBackgroundColor:[UIColor colorWithHex:@"#ffffff"]];

//根据textOrBack判断是日期变色还是背景变色

if (self.textOrBack == 1) {

[cell.CalendarDateLabel setTextColor:self.dateColor];

break ;

}

else if(self.textOrBack == 2){

[cell setBackgroundColor:self.dateColor];

break ;

}

else{

//改变字体颜色

//                        [cell.CalendarDateLabel setBackgroundColor:self.dateColor];

[cell.CalendarDateLabel setTextColor:self.dateColor];

break ;

}

break ;

}

}

}

//重载方法2有数据的日期

if (self.dataDictArr.count > 0) {

NSString * date = [ConvertDate ConvertDateWithYear:self.yearsNum

months:self.monthsNum

day:indexPath.row - self.firsrtDay+1] ;

for (NSInteger i = 0 ; i < self.dataDictArr.count ; i ++) {

//dataArr里面的数据为:dataArr = @[@[保存日期的字典, 保存日期的字典, 保存日期的字典],颜色]

NSArray * dataArr = self.dataDictArr[i] ;

for (NSInteger j = 0 ; j < [dataArr[0] count ]; j ++) {

NSDictionary * dataDict = dataArr[0][j] ;

if ([date isEqualToString:dataDict[self.key]]){

//根据textOrBack判断是日期变色还是背景变色

if (self.textOrBack == 1) {

[cell.CalendarDateLabel setTextColor:dataArr[1]];

break ;

}

else if(self.textOrBack == 2){

[cell setBackgroundColor:dataArr[1]];

break ;

}

else{

//                            [cell.CalendarDateLabel setBackgroundColor:dataArr[1]];

if (j == 3) {

cell.LeaveImg.hidden = NO;

}else if (j == 4){

[cell.SubscriptLabel setText:@"复测"];

}else{

[cell.CalendarDateLabel setTextColor:dataArr[1]];

}

break ;

}

}

}

}

}

if (self.calendarModel && _calendarModelNum == 1) {

NSString * date = [ConvertDate ConvertDateWithYear:self.yearsNum

months:self.monthsNum

day:indexPath.row - self.firsrtDay+1];

for (MTLogDataModel *dataArray in self.calendarModel.logData){

NSString * calendardate = @"";

//                DLog(@"dataArray.date: %@",[calendardate timeWithTimeIntervalString:dataArray.date]);

calendardate = [calendardate timeWithTimeIntervalString:dataArray.date];

if ([calendardate isEqualToString:date]) {

cell.LogDataModel = dataArray;

}

}

}

//今天的日期的颜色

if ([[ConvertDate ConvertDateWithYear:self.yearsNum months:self.monthsNum day:indexPath.row - self.firsrtDay+1] isEqualToString:[self NSDateToNSString:[NSDate date]]]){

[cell.CalendarDateLabel setBackgroundColor:[UIColor colorWithHex:@"#3FAAF4"]];

[cell setBackgroundColor:self.colorArr.count > 0?self.colorArr[1]:[UIColor colorWithHex:@"#ffffff"]];

cell.Circle.progressColor = [UIColor colorWithHex:@"#F2F9FE"];

cell.Circle.fillColor = [UIColor colorWithHex:@"#AFDCFA"];

cell.Circle.backColor = [UIColor colorWithHex:@"#53B3F5"];

}

[cell.CalendarDateLabel setText:[NSString stringWithFormat:@"%ld",indexPath.row - self.firsrtDay+1]];

}

else{

//这个月最后一天之后的那些cell

[cell.CalendarDateLabel setBackgroundColor:[UIColor clearColor]];

[cell setBackgroundColor:[UIColor clearColor]];

[cell.CalendarDateLabel setTextColor:[UIColor clearColor]];

[cell.CalendarDateLabel setText:[NSString stringWithFormat:@"%ld",(long)self.nxetMonthDays]];

_endDate = @"0";

_endDate = [NSString stringWithFormat:@"%ld",(long)self.nxetMonthDays];

self.nxetMonthDays ++ ;

}

if (self.StartorEndDateBlock && _indexPathNum == 42 && indexPath.row == 41) {

self.StartorEndDateBlock(_startDate,_endDate);

_indexPathNum  = 0;

}

*/

相关文章

网友评论

      本文标题:UICollectionViewCell的赋值方法

      本文链接:https://www.haomeiwen.com/subject/xgthrxtx.html