123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- //
- // DayCollectionViewCell.m
- // BJTResearch
- //
- // Created by yunlong on 17/5/11.
- // Copyright © 2017年 yunlong. All rights reserved.
- //
- #import "DayCollectionViewCell.h"
- #import "MonthModel.h"
- #import "ADHTuanCan-Swift.h"
- #define NormalColor [UIColor whiteColor]
- #define StartAndEndColor [UIColor colorWithRed:198/255.0 green:34/255.0 blue:35/255.0 alpha:1.0]
- #define SelectedColor [UIColor colorWithRed:198/255.0 green:34/255.0 blue:35/255.0 alpha:1.0]
- @interface DayCollectionViewCell ()
- @property(nonatomic,strong) UILabel *gregorianCalendarLabel;
- @property(nonatomic,strong) UILabel *lunarCalendarLabel;
- @end
- @implementation DayCollectionViewCell
- - (instancetype)initWithFrame:(CGRect)frame
- {
- self = [super initWithFrame:frame];
- if (self) {
- self.backgroundColor = [UIColor whiteColor];
- self.gregorianCalendarLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height/2)];
- self.gregorianCalendarLabel.textAlignment = NSTextAlignmentCenter;
- self.gregorianCalendarLabel.font = [UIFont systemFontOfSize:12];
- self.gregorianCalendarLabel.textColor = [UIColor blackColor];
- self.gregorianCalendarLabel.backgroundColor = [UIColor clearColor];
- [self.contentView addSubview:self.gregorianCalendarLabel];
-
- self.lunarCalendarLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, self.self.bounds.size.height/2, self.bounds.size.width, self.bounds.size.height/2)];
- self.lunarCalendarLabel.textAlignment = NSTextAlignmentCenter;
- self.lunarCalendarLabel.font = [UIFont systemFontOfSize:12];
- self.lunarCalendarLabel.textColor = [UIColor blackColor];
- self.lunarCalendarLabel.backgroundColor = [UIColor clearColor];
- [self.contentView addSubview:self.lunarCalendarLabel];
-
- }
- return self;
- }
- -(void)setModel:(DayModel *)model{
- _model = model;
- if (model == nil) {
- self.gregorianCalendarLabel.text = @"";
- self.lunarCalendarLabel.text = @"";
- self.backgroundColor = NormalColor;
- }else{
- // if (model.isToday) {//是今天
- self.gregorianCalendarLabel.text = [NSString stringWithFormat:@"%02ld",model.day];
- NSString *string = [LanguagesUtil createTextByCtext:[NSString stringWithFormat:@"第%D天",model.Daysort] Etext:[NSString stringWithFormat:@"the%Dday",model.Daysort]];
- self.lunarCalendarLabel.text = string;
- if (model.Daysort > 0){
- self.lunarCalendarLabel.text = string;
- }else{
- self.lunarCalendarLabel.text = @"";
- }
- self.lunarCalendarLabel.textColor = [UIColor blackColor];
- self.gregorianCalendarLabel.textColor = [UIColor blackColor];
-
- self.layer.cornerRadius = 0;
-
- if (model.isStatePast) {
- self.userInteractionEnabled = NO;
- self.lunarCalendarLabel.textColor = [UIColor grayColor];
- self.gregorianCalendarLabel.textColor = [UIColor grayColor];
- }else{
- self.userInteractionEnabled = YES;
- self.lunarCalendarLabel.textColor = [UIColor blackColor];
- self.gregorianCalendarLabel.textColor = [UIColor blackColor];
- }
-
-
- switch (model.state) {
- case DayModelStateNormal:{
- self.backgroundColor = NormalColor;
- UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerBottomLeft | UIRectCornerTopRight | UIRectCornerBottomRight cornerRadii:CGSizeMake(0, 0)];
- CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
- maskLayer.frame = self.bounds;
- maskLayer.path = maskPath.CGPath;
- self.layer.mask = maskLayer;
- break;
- }
- case DayModelStateStart:{
- self.backgroundColor = StartAndEndColor;
- self.lunarCalendarLabel.textColor = [UIColor whiteColor];
- // self.gregorianCalendarLabel.text = @"入住";
- self.gregorianCalendarLabel.textColor = [UIColor whiteColor];
- // self.layer.cornerRadius = 30;
- if (model.isEndTimeOK)
- {
- UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerBottomLeft cornerRadii:CGSizeMake(30, 30)];
- CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
- maskLayer.frame = self.bounds;
- maskLayer.path = maskPath.CGPath;
- self.layer.mask = maskLayer;
- }else{
- UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerBottomLeft | UIRectCornerTopRight | UIRectCornerBottomRight cornerRadii:CGSizeMake(0, 0)];
- CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
- maskLayer.frame = self.bounds;
- maskLayer.path = maskPath.CGPath;
- self.layer.mask = maskLayer;
- self.layer.cornerRadius = 30;
- }
-
-
- break;
- }
- case DayModelStateEnd:{
- self.backgroundColor = StartAndEndColor;
- self.lunarCalendarLabel.textColor = [UIColor whiteColor];
- // self.gregorianCalendarLabel.text = @"离店";
- self.gregorianCalendarLabel.textColor = [UIColor whiteColor];
- // self.layer.cornerRadius = 30;
-
- UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:UIRectCornerTopRight | UIRectCornerBottomRight cornerRadii:CGSizeMake(30, 30)];
- CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
- maskLayer.frame = self.bounds;
- maskLayer.path = maskPath.CGPath;
- self.layer.mask = maskLayer;
-
- break;
- }
- case DayModelStateSelected:{
- self.backgroundColor = SelectedColor;
- self.lunarCalendarLabel.textColor = [UIColor whiteColor];
- self.gregorianCalendarLabel.textColor = [UIColor whiteColor];
- UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerBottomLeft | UIRectCornerTopRight | UIRectCornerBottomRight cornerRadii:CGSizeMake(0, 0)];
- CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
- maskLayer.frame = self.bounds;
- maskLayer.path = maskPath.CGPath;
- self.layer.mask = maskLayer;
- break;
- }
- default:
- break;
-
- }
- }
-
- }
- @end
|