// // WD_DetailCoaCell.m // LNManager // // Created by EchoShacolee on 2017/6/8. // Copyright © 2017年 lee. All rights reserved. // #import "WD_DetailCoaCell.h" @interface WD_DetailCoaCell () { UILabel *_nameLab; UILabel *_sexLab; UILabel *_levelLab; UILabel *_cardIdLab; UILabel *_addressLab; UILabel *_connectTelLab; UILabel *_carTypeLab; UIView *_view; UIView *_bottomView; } @end @implementation WD_DetailCoaCell +(WD_DetailCoaCell *)cellForTableView:(UITableView *)tableView{ WD_DetailCoaCell * cell = [tableView dequeueReusableCellWithIdentifier:@"WD_DetailCoaCell"]; if (!cell) { cell = [[WD_DetailCoaCell alloc]initWithStyle:0 reuseIdentifier:@"WD_DetailCoaCell"]; } return cell; } -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { self.tintColor = COLOR_THEME; _view = [UIView new]; _view.backgroundColor = KBackGroundColor; [self.contentView addSubview:_view]; _bottomView = [UIView new]; _bottomView.backgroundColor = KBackGroundColor; [self.contentView addSubview:_bottomView]; // NSMutableArray *mArr = [NSMutableArray new]; for (int i=0; i<7; i++) { UILabel *lab = [[UILabel alloc]init]; lab.font = [UIFont systemFontOfSize:14]; [mArr addObject:lab]; [self.contentView addSubview:lab]; } _nameLab = mArr[0]; _levelLab = mArr[1]; _sexLab = mArr[2]; _cardIdLab = mArr[3]; _addressLab = mArr[4]; _carTypeLab = mArr[5]; _connectTelLab = mArr[6]; _levelLab.textAlignment = NSTextAlignmentRight; _sexLab.textAlignment = NSTextAlignmentCenter; _nameLab.textColor = COLOR_THEME; } return self; } -(void)setDic:(NSDictionary *)dic{ if (_dic != dic) { _nameLab.text = dic[@"CI_NAME"]; NSString *sex = [NSString stringWithFormat:@"%@",dic[@"CI_SEX"]]; _sexLab.text = [sex isEqualToString:@"1"] ? @"男" : @"女" ; NSString *status = [NSString stringWithFormat:@"%@",dic[@"CI_OCCUPATIONLEVEL"]]; NSString *levelStr = @"暂无"; switch ([status integerValue]) { case 1: levelStr = @"一级"; break; case 2: levelStr = @"二级"; break; case 3: levelStr = @"三级"; break; case 4: levelStr = @"四级"; break; default: break; } _levelLab.text = [@"资格等级:" stringByAppendingString:levelStr]; _cardIdLab.text = [NSString stringWithFormat:@"驾驶证号:%@",dic[@"CI_DRILICENCE"]]; _addressLab.text = [NSString stringWithFormat:@"所属驾校:%@",dic[@"SCHOOLNAME"]]; _connectTelLab.text =[NSString stringWithFormat:@"联系电话:%@",dic[@"CI_MOBILE"]]; _carTypeLab.text =[NSString stringWithFormat:@"准教车型:%@",dic[@"CI_TEACHPERMITTED"]]; } } -(void)layoutSubviews{ [super layoutSubviews]; CGFloat wid = self.width; CGFloat x,y,w,h,bd; x = -50; w = wid+50; y = 0; h = 10; _view.frame = setDIYFrame; x = 10; w = [_nameLab.text sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]}].width; y = 20; h = 17; bd = 10; _nameLab.frame = setDIYFrame; w = [_sexLab.text sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]}].width; _sexLab.frame = setDIYFrame; _sexLab.center = CGPointMake(wid/2-40, y+h/2); w = [_levelLab.text sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]}].width; x = wid-w-10; _levelLab.frame = setDIYFrame; x = 10; w = wid-20; y += h+bd; _cardIdLab.frame = setDIYFrame; y += h+bd; _addressLab.frame = setDIYFrame; y += h+bd; _connectTelLab.frame = setDIYFrame; y += h+bd; _carTypeLab.frame = setDIYFrame; x = -50; w = wid+50; y +=10+h; h = 10; _bottomView.frame = setDIYFrame; //165 } - (void)awakeFromNib { [super awakeFromNib]; // Initialization code } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } @end