// // OneImageCell.m // 千模 // // Created by MUMEI on 2018/6/7. // Copyright © 2018年 MUMEI. All rights reserved. // #import "OneImageCell.h" #import "UILabel+LabelHeightAndWidth.h" @implementation OneImageCell - (void)awakeFromNib { [super awakeFromNib]; // [self buildLabelOne]; // Initialization code } - (void)setModel:(PrivateModel *)model{ _model = model; self.detailLabel.text = model.intro; [self buildLabelOne]; NSString *now = [Helper getCurrentTimes]; NSString *lastDay = [Helper getLastTimes]; NSArray * dateNow = [now componentsSeparatedByString:@" "]; NSArray * nowYMD = [dateNow[0] componentsSeparatedByString:@"-"]; NSString * nowY = nowYMD[0]; NSString * nowM = nowYMD[1]; NSString * nowD = nowYMD[2]; NSArray * dateLast = [lastDay componentsSeparatedByString:@" "]; NSArray * lastYMD = [dateLast[0] componentsSeparatedByString:@"-"]; NSString * lastY = lastYMD[0]; NSString * lastM = lastYMD[1]; NSString * lastD = lastYMD[2]; NSArray * date = [model.pdate componentsSeparatedByString:@" "]; NSString * date2 = date[0]; NSArray * YMD = [date2 componentsSeparatedByString:@"-"]; NSString * Y = YMD[0]; NSString * M = YMD[1]; NSString * D = YMD[2]; if ([Y isEqualToString:nowY]) { if ([M isEqualToString:nowM]) { if ([D isEqualToString:nowD]) { D = @"今天"; self.Day.text = @""; self.Month.hidden = YES; self.noMonth = YES; } } } if ([Y isEqualToString:lastY]) { if ([M isEqualToString:lastM]) { if ([D isEqualToString:lastD]) { D = @"昨天"; self.Day.text = D; self.Month.hidden = YES; self.noMonth = YES; } } } if (!self.noMonth) { if([M isEqualToString:@"01"]){ M = @"1"; }else if ([M isEqualToString:@"02"]){ M = @"2"; }else if ([M isEqualToString:@"03"]){ M = @"3"; }else if ([M isEqualToString:@"04"]){ M = @"4"; }else if ([M isEqualToString:@"05"]){ M = @"5"; }else if ([M isEqualToString:@"06"]){ M = @"6"; }else if ([M isEqualToString:@"07"]){ M = @"7"; }else if ([M isEqualToString:@"08"]){ M = @"8"; }else if ([M isEqualToString:@"09"]){ M = @"9"; }else if ([M isEqualToString:@"10"]){ M = @"10"; }else if ([M isEqualToString:@"11"]){ M = @"11"; }else if ([M isEqualToString:@"12"]){ M = @"12"; } self.Day.text = D; self.Month.text = [NSString stringWithFormat:@"%@月",M]; } NSString *url = [model.iteminfo[0] objectForKey:@"url"]; [self.oneImage sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",imageURl,url]] placeholderImage:[UIImage imageNamed:@"jiazai"]]; NSLog(@"date = %@",[Helper sharedAccount].date); UITapGestureRecognizer *Tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(toImage:)];; [self.oneImage addGestureRecognizer:Tap]; self.oneImage.userInteractionEnabled = YES; // if([[Helper sharedAccount].date isEqualToString:date2]){ // self.Day.hidden = YES; // self.Month.hidden = YES; // } // [Helper sharedAccount].date = date2; if ([model.isditto isEqualToString:@"1"]) { self.Day.hidden = YES; self.Month.hidden = YES; } } - (void)toImage:(UITapGestureRecognizer*)recognizer { [self.delegate clickImage:_model andNum:0]; } #pragma mark - labelOne SizeToFitHeight - (void)buildLabelOne { self.detailLabel.text = _model.intro; _detailLabel.font = [UIFont systemFontOfSize:15]; _detailLabel.numberOfLines = 0; CGFloat height = [UILabel getHeightByWidth:_detailLabel.frame.size.width title:_detailLabel.text font:_detailLabel.font]; if (height>80) { height = 80; } _detailLabel.frame = CGRectMake(210, 15, 135, height); } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } @end