123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253 |
- //
- // EvaListCell.m
- // LN_School
- //
- // Created by EchoShacolee on 2017/6/15.
- // Copyright © 2017年 Danson. All rights reserved.
- //
- #import "EvaListCell.h"
- #import "RatingBar.h"
- @interface EvaListCell()
- {
-
- UILabel *_coach;
- UILabel *_school;
- UILabel *_srvmanner;
- UILabel *_star;
- UILabel *_subject;
- UILabel *_teachLevel;
- UILabel *_student;
- UILabel *_time;
-
- UIView *_view;
- RatingBar *_starBar;
- UIView * _srvmannerView;
- }
- @end
- @implementation EvaListCell
- +(EvaListCell *)cellForTabelView:(UITableView *)tableView{
-
- EvaListCell* cell = [tableView dequeueReusableCellWithIdentifier:@"EvaListCell"];
- if (!cell) {
- cell = [[EvaListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"EvaListCell"];
- }
- return cell;
- }
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
- if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
-
- self.selectionStyle = UITableViewCellSelectionStyleNone;
-
- NSArray * textArr = @[@"教练名字",@"机构名字",@"srvmanner",@"星级",@"科目",@"评价内容",@"时间",@"学员"];
- NSMutableArray * labArr = [NSMutableArray new];
- //
- for (int i=0; i<textArr.count; i++) {
- UILabel * lab = [[UILabel alloc]init];
- lab.textColor = [UIColor blackColor];
- lab.textAlignment = NSTextAlignmentLeft;
- lab.font = [UIFont systemFontOfSize:14];
- [self.contentView addSubview:lab];
- [labArr addObject:lab];
- }
- _coach = labArr[0];
- _school = labArr[1];
- _srvmanner = labArr[2];
- _star = labArr[3];
- _subject = labArr[4];
- _teachLevel = labArr[5];
- _time = labArr[6];
- _student = labArr[7];
-
- _time.textAlignment = NSTextAlignmentRight;
- _time.textColor = [UIColor lightGrayColor];
- _time.font = [UIFont systemFontOfSize:12];
-
- _teachLevel.numberOfLines = 0;
-
- _srvmanner.numberOfLines = 0;
-
- _subject.textAlignment = NSTextAlignmentRight;
-
- _starBar = [[RatingBar alloc]initWithFrame:CGRectMake(0, 0, 70, 17) Flag:YES];
- _starBar.enable = NO;
- [self.contentView addSubview:_starBar];
-
- //
- _view = [UIView new];
- _view.backgroundColor = KBackGroundColor;
- [self.contentView addSubview:_view];
-
- //
- _srvmannerView = [UIView new];
- [self.contentView addSubview:_srvmannerView];
- }
- return self;
- }
- - (void)layoutSubviews {
- [super layoutSubviews];
-
- [super layoutSubviews];
- CGFloat wid = self.width;
- CGFloat x,y,w,h,bd;
-
- x = 0;
- w = wid;
- y = 0;
- h = 20;
- _view.frame = KSetDIYFrame;
-
- y += 5;
-
- x = 20;
- y += h;
- bd = 5;
- w = wid - 40;
- h = 17;
- y += bd;
- _coach.frame = KSetDIYFrame;
- _time.frame = KSetDIYFrame;
-
- y += h+bd;
- h = 17;
- _school.frame = KSetDIYFrame;
- if (_time.frame.size.height == 0) {
- _time.frame = KSetDIYFrame;
- }
-
- y += h;
- h = [_teachLevel.text heightForWid:w Font:14];
- if (h != 0) {
- y += bd;
- }
- _teachLevel.frame = KSetDIYFrame;
-
- y += h;
- if (_srvmanner.text.length != 0) {
- y += bd;
- h = 17;
- }else{
- h = 0;
- }
- _srvmannerView.frame = KSetDIYFrame;
-
- y += h+bd;
- h = 17;
- _subject.frame = KSetDIYFrame;
- w = 70;
- _star.frame = KSetDIYFrame;
- x += w;
- y += 3;
- w = 80;
- _starBar.frame = KSetDIYFrame;
-
- // y += h;
- // _student.frame = KSetDIYFrame;
- }
- - (void)updateWithDic:(NSDictionary *)dic {
- //NSArray * textArr = @[@"教练名字",@"机构名字",@"srvmanner",@"星级",@"科目",@"评价内容",@"时间",@"学员"];
- NSString *type = [NSString stringWithFormat:@"%@",dic[@"TYPE"]];
- if ([type isEqualToString:@"1"]) {
- _coach.text = [NSString stringWithFormat:@"被评价教练 :%@",dic[@"OBJNAME"]];
- _school.text = [NSString stringWithFormat:@"所属驾校 :%@",dic[@"SCHNAME"]];
- }else{
-
- _coach.text = @"";
- _school.text = [NSString stringWithFormat:@"被评价驾校 :%@",dic[@"OBJNAME"]];
- }
-
- for (UIView * subV in _srvmannerView.subviews) {
- [subV removeFromSuperview];
- }
- if ([dic[@"EI_SRVMANNER"] length] != 0) {
- _srvmanner.text = dic[@"EI_SRVMANNER"];
- NSArray * array = [dic[@"EI_SRVMANNER"] componentsSeparatedByString:@","];
- [self createLabViewsWithArray:array];
- }else{
- _srvmanner.text = @"";
- }
-
-
- if ([dic[@"EI_TEACHLEVEL"] length] != 0) {
- _teachLevel.text = [NSString stringWithFormat:@"评价内容 :%@",dic[@"EI_TEACHLEVEL"]];
- }else{
-
- _teachLevel.text = @"";
- }
-
- _star.text = [NSString stringWithFormat:@"评价星级 :"];
- _starBar.starNumber = [[NSString stringWithFormat:@"%@",dic[@"STAR"]] integerValue];
- NSString * kemu = @"";
- switch ([[NSString stringWithFormat:@"%@",dic[@"PART"]] integerValue]) {
- case 1:
- kemu = @"一";
- break;
- case 2:
- kemu = @"二";
- break;
- case 3:
- kemu = @"三";
- break;
- case 4:
- kemu = @"四";
- break;
-
- default:
- break;
- }
-
- _subject.text = [NSString stringWithFormat:@"培训科目 :科目%@",kemu];
- _time.text = [NSString stringWithFormat:@"%@",dic[@"CRTIME"]];
-
- _student.text = [NSString stringWithFormat:@"学员 :%@",dic[@"STUDENGNAME"]];
- }
- -(void)createLabViewsWithArray:(NSArray *)array{
-
- //lableview
-
- UILabel * lable;
- CGFloat x = 0;
- CGFloat y = 0;
- CGFloat w = 0;
- CGFloat h = 17;
- CGFloat bd = 20;
-
- for (int i=0;i<array.count;i++) {
-
- NSString * contentStr = array[i];
- CGSize size =[contentStr sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]}];
- w = size.width;
- lable = [[UILabel alloc] initWithFrame:CGRectMake(x, y, w, h)];
- x += bd+w;
- lable .text = contentStr;
- lable.textColor = RQMianColor;
- lable.font = [UIFont systemFontOfSize:13];
- lable.textAlignment = NSTextAlignmentCenter;
-
- lable.layer.borderWidth = 0.5;
- lable.layer.borderColor = RQMianColor.CGColor;
-
- [_srvmannerView addSubview:lable];
- }
- }
- - (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
|