OrderCommentCell.m 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. //
  2. // OrderCommentCell.m
  3. // jiaPei
  4. //
  5. // Created by apple on 16/6/30.
  6. // Copyright © 2016年 JCZ. All rights reserved.
  7. //
  8. #import "OrderCommentCell.h"
  9. @implementation OrderCommentCell
  10. - (void)awakeFromNib {
  11. [super awakeFromNib];
  12. // Initialization code
  13. }
  14. -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  15. {
  16. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  17. if (self) {
  18. self.backgroundColor = [UIColor whiteColor];
  19. NSMutableArray *labelArray = [NSMutableArray array];
  20. for (int i = 0; i < 6; i ++) {
  21. UILabel *label = [UILabel new];
  22. [self.contentView addSubview:label];
  23. [labelArray addObject:label];
  24. }
  25. nameLabel = labelArray[0];
  26. dateLabel = labelArray[1];
  27. contentLabel = labelArray[5];
  28. contentLabel.numberOfLines = 0;
  29. tag1Label = labelArray[2];
  30. [tag1Label borderColor:RQMianColor width:1.0 cornorRadios:5];
  31. tag2Label = labelArray[3];
  32. [tag2Label borderColor:RQMianColor width:1.0 cornorRadios:5];
  33. tag3Label = labelArray[4];
  34. [tag3Label borderColor:RQMianColor width:1.0 cornorRadios:5];
  35. starImageView = nil;
  36. }
  37. return self;
  38. }
  39. -(void)setDataDic:(NSDictionary *)dataDic
  40. {
  41. _dataDic = dataDic;
  42. [nameLabel setText:dataDic[@"TSO_NAME"] Font:Font18 TextColor:KTitleColor Alignment:NSTextAlignmentLeft];
  43. NSString *dateString = dataDic[@"EVALUATETIME"];
  44. if (dateString.length > 16) {
  45. dateString = [dataDic[@"EVALUATETIME"] substringToIndex:16];
  46. }
  47. [dateLabel setText:dateString Font:Font16 TextColor:KContentTextColor Alignment:NSTextAlignmentRight];
  48. }
  49. -(void)layoutSubviews
  50. {
  51. //cell的高度 可变+95
  52. CGFloat x,y,w,h;
  53. x = 20;
  54. y = 5;
  55. w = 80;
  56. h = 25;
  57. nameLabel.frame = KSetDIYFrame;
  58. [nameLabel addViewWithRect:CGRectMake(10, h + 4, kSize.width - 20, 1)];
  59. x += w;
  60. w = kSize.width - x -20;
  61. dateLabel.frame = KSetDIYFrame;
  62. x = 20;
  63. y += h + 10;
  64. h = 16;
  65. w = h*4.98;
  66. if (!starImageView) {
  67. starImageView = [[CDPStarEvaluation alloc] initWithFrame:CGRectMake(x, y, w, h) onTheView:self.contentView];
  68. }
  69. [starImageView setStarWithFloat:[_dataDic[@"EI_OVERALL"] floatValue]/5.0];
  70. y += h + 4;
  71. w = kSize.width - 40;
  72. h = [_dataDic[@"EI_TEACHLEVEL"] heightForWid:w Font:Font16];
  73. contentLabel.frame = KSetDIYFrame;
  74. [contentLabel setText:_dataDic[@"EI_TEACHLEVEL"] Font:Font16 TextColor:KTitleColor Alignment:NSTextAlignmentLeft];
  75. y += h + 10;
  76. h = 25;
  77. NSArray *array = [_dataDic[@"EI_SRVMANNER"] componentsSeparatedByString:@","];
  78. if (array.count > 0) {
  79. CGSize size = [array[0] sizeForFont:Font17];
  80. w = size.width + 8;
  81. tag1Label.frame = KSetDIYFrame;
  82. [tag1Label setText:array[0] Font:Font17 TextColor:RQMianColor Alignment:NSTextAlignmentCenter];
  83. }
  84. if (array.count > 1) {
  85. x += w + 10;
  86. CGSize size = [array[1] sizeForFont:Font17];
  87. w = size.width + 8;
  88. tag2Label.frame = KSetDIYFrame;
  89. [tag2Label setText:array[1] Font:Font17 TextColor:RQMianColor Alignment:NSTextAlignmentCenter];
  90. }
  91. if (array.count > 2) {
  92. x += w + 10;
  93. CGSize size = [array[2] sizeForFont:Font17];
  94. w = size.width + 8;
  95. tag3Label.frame = KSetDIYFrame;
  96. [tag3Label setText:array[2] Font:Font17 TextColor:RQMianColor Alignment:NSTextAlignmentCenter];
  97. }
  98. [tag1Label addViewWithRect:CGRectMake(0, y + h + 5, kSize.width, 5)];
  99. }
  100. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  101. [super setSelected:selected animated:animated];
  102. }
  103. @end