// // TrainDetailCell.m // jiaPei // // Created by apple on 2017/3/10. // Copyright © 2017年 JCZ. All rights reserved. // #import "TrainDetailCell.h" @implementation TrainDetailCell - (void)awakeFromNib { [super awakeFromNib]; _titleLabel.font = [UIFont scaleSize:18]; _contentLabel.font = [UIFont scaleSize:15]; [_orbitBtn borderColor:defGreen width:1 cornorRadios:5]; [_orbitBtn setTitle:@"查看轨迹" textColor:defGreen font:15 fotState:UIControlStateNormal]; [_commentBtn borderColor:defGreen width:1 cornorRadios:5]; [_commentBtn setTitle:@"评价" textColor:defGreen font:15 fotState:UIControlStateNormal]; [_commentBtn setTitle:@"查看评价" textColor:defGreen font:15 fotState:UIControlStateSelected]; } -(void)updateWith:(NSDictionary *)dic{ if ([dic[@"CRI_STU_EVALUATE"] isEqualToString:@"1"]) { _commentBtn.selected = YES; }else{ _commentBtn.selected = NO; } if ([dic[@"CRI_ENDTIME"] length] > 10) { _titleLabel.text = [NSString stringWithFormat:@"%@----%@",dic[@"CRI_STARTTIME"],[dic[@"CRI_ENDTIME"] substringFromIndex:10]]; }else{ _titleLabel.text = [NSString stringWithFormat:@"%@----%@",dic[@"CRI_STARTTIME"],dic[@"CRI_ENDTIME"]]; } int time = [dic[@"CRI_VAILD_TIME"] intValue]; int min = time%60; int hour = time/60; NSString *timeString = [NSString stringWithFormat:@"%d小时%d分钟",hour,min]; if (hour == 0){ timeString = [NSString stringWithFormat:@"%d分钟",min]; } time = [dic[@"CRI_DURATION"] intValue]; min = time%60; hour = time/60; NSString *valueTimeString = [NSString stringWithFormat:@"%d小时%d分钟",hour,min]; if (hour == 0){ valueTimeString = [NSString stringWithFormat:@"%d分钟",min]; } _contentLabel.text = [NSString stringWithFormat:@"持续时间:%@ 有效时间:%@",valueTimeString,timeString]; _checkMan.text = [NSString stringWithFormat:@"审核人 :%@",dic[@"CRI_AUDIT_USERNAME"]]; _reasonLabel.text = [NSString stringWithFormat:@"审核原因:%@",dic[@"CRI_SECOND_AUDIT_REASON"]]; _timeLab.text = [NSString stringWithFormat:@"审核时间:%@",dic[@"CRI_AUDIT_TIME"]]; _statusLabel.text = [NSString stringWithFormat:@"%@",dic[@"CRI_SECOND_AUDIT_RESULT"]]; if ([_statusLabel.text isEqualToString:@"0"]) { _statusLabel.text = @"审核通过"; _statusLabel.textColor = [UIColor darkGrayColor]; [self hiddenSecondCheck:YES]; }else if ([_statusLabel.text isEqualToString:@"1"]) { _statusLabel.text = @"审核不通过"; _statusLabel.textColor = [UIColor redColor]; [self hiddenSecondCheck:NO]; }else if ([_statusLabel.text isEqualToString:@"2"]) { _statusLabel.text = @"待审核"; _statusLabel.textColor = [UIColor lightGrayColor]; [self hiddenSecondCheck:YES]; } NSString *reasonStr = dic[@"CRI_AUDIT_REASON"]? : @""; if (![_statusLabel.text isEqualToString:@"1"] && ![reasonStr isEqualToString:@""]) { _reasonLabel.text = [NSString stringWithFormat:@"审核原因:%@",reasonStr]; _reasonLabel.textColor = [UIColor systemRedColor]; _checkMan.hidden = YES; _reasonLabel.hidden = NO; _timeLab.hidden = YES; _statusLabel.hidden = YES; _reasonLabelTop.constant = -25; _orbitBtnTop.constant = -25; }else { _reasonLabelTop.constant = 0; _orbitBtnTop.constant = -70; } } -(void)hiddenSecondCheck:(BOOL)hidden{ if (hidden) { _orbitBtnTop.constant = -70; }else{ _orbitBtnTop.constant = 5; } _checkMan.hidden = hidden; _reasonLabel.hidden = hidden; _timeLab.hidden = hidden; _statusLabel.hidden = hidden; } + (CGFloat)heightForDic:(NSDictionary *)dic { // 而高度是动态返回 CGRect bounds = [[NSString stringWithFormat:@"审核原因:%@",dic[@"CRI_SECOND_AUDIT_REASON"]] boundingRectWithSize:CGSizeMake(kSize.width-41, 1000) options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:15] forKey:NSFontAttributeName] context:nil]; CGRect bounds0 = [[NSString stringWithFormat:@"审核原因:%@",dic[@"CRI_AUDIT_REASON"]] boundingRectWithSize:CGSizeMake(kSize.width-41, 1000) options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:15] forKey:NSFontAttributeName] context:nil]; BOOL showSecondCheck = [[NSString stringWithFormat:@"%@",dic[@"CRI_SECOND_AUDIT_RESULT"]] isEqualToString:@"1"]; BOOL showCheck = [NSString stringWithFormat:@"%@",dic[@"CRI_AUDIT_REASON"]].length > 0; if (showSecondCheck) { return 140 + (bounds.size.height > 25 ? bounds.size.height : 25); }else if (showCheck){ return 90 + (bounds0.size.height > 25 ? bounds0.size.height : 25); } return 90; } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } @end