PlanCell.m 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. //
  2. // PlanCell.m
  3. // jiaPeiC
  4. //
  5. // Created by apple on 15/12/18.
  6. // Copyright © 2015年 JCZ. All rights reserved.
  7. //
  8. #import "PlanCell.h"
  9. @interface PlanCell()
  10. @end
  11. @implementation PlanCell
  12. - (void)awakeFromNib {
  13. [super awakeFromNib];
  14. }
  15. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  16. [super setSelected:selected animated:animated];
  17. }
  18. -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  19. {
  20. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  21. if (self) {
  22. UILabel* label;UIImageView* iv;UIButton* btn;
  23. label = [UILabel new];
  24. [self addSubview:label];
  25. lblDate = label;
  26. label = [UILabel new];
  27. [self addSubview:label];
  28. lblName = label;
  29. label = [UILabel new];
  30. [self addSubview:label];
  31. lblNum = label;
  32. label = [UILabel new];
  33. [self addSubview:label];
  34. titNum = label;
  35. label = [UILabel new];
  36. [self addSubview:label];
  37. titDate = label;
  38. label = [UILabel new];
  39. [self addSubview:label];
  40. titCount = label;
  41. label = [UILabel new];
  42. [self addSubview:label];
  43. countLabel = label;
  44. iv = [UIImageView new];
  45. [self addSubview:iv];
  46. imgDate = iv;
  47. iv = [UIImageView new];
  48. [self addSubview:iv];
  49. imgNum = iv;
  50. btn = [UIButton new];
  51. [self addSubview:btn];
  52. btnScan = btn;
  53. // [imgNum imageName:@"send_time_icon.png"];
  54. [imgNum setImage:[UIImage imageNamed:@"send_time_icon.png"]];
  55. [imgDate setImage:[UIImage imageNamed:@"send_people_num_icon.png"]];
  56. // [imgDate imageName:@"send_people_num_icon.png"];
  57. [titNum setFont:[UIFont scaleSize:NormalFont]];
  58. [titDate setFont:[UIFont scaleSize:NormalFont]];
  59. [self.textLabel setFont:[UIFont scaleSize:NormalFont]];
  60. [self.detailTextLabel setFont:[UIFont scaleSize:NormalFont]];
  61. [titCount setFont:[UIFont scaleSize:NormalFont]];
  62. [countLabel setFont:[UIFont scaleSize:FontTitle]];
  63. [lblNum setFont:[UIFont scaleSize:FontTitle]];
  64. [lblDate setFont:[UIFont scaleSize:FontTitle]];
  65. lblDate.numberOfLines = 0;
  66. [btnScan setTitleColor:defGreen forState:UIControlStateNormal];
  67. }
  68. return self;
  69. }
  70. +(PlanCell*)cellForTabelView:(UITableView*)tableView
  71. {
  72. PlanCell* cell = [tableView dequeueReusableCellWithIdentifier:@"PlanCell"];
  73. if (!cell) {
  74. cell = [[PlanCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"PlanCell"];
  75. }
  76. return cell;
  77. }
  78. -(void)setModel:(NSDictionary *)model
  79. {
  80. _model = model;
  81. [self.textLabel setText:model[@"title"]];
  82. [self.detailTextLabel setText:model[@"content"]];
  83. [lblName setText:model[@"userName"]];
  84. [lblNum setText:model[@"num"]];
  85. [lblDate setText:[NSString stringWithFormat:@"%@\n%@",model[@"taskTime"],model[@"times"]]];
  86. [countLabel setText:model[@"havNum"]];
  87. [titDate setText:@"预约时间:"];
  88. [titNum setText:@"可预约人数:"];
  89. [titCount setText:@"已预约人数:"];
  90. [btnScan setTitle:@"查看预约" forState:UIControlStateNormal];
  91. }
  92. -(void)layoutSubviews
  93. {
  94. [super layoutSubviews];
  95. CGFloat wid = self.width;
  96. // CGFloat hei = self.height;
  97. // SetRandomColor(btnScan);
  98. // SetRandomColor(self.textLabel);
  99. // SetRandomColor(self.detailTextLabel);
  100. CGFloat x,y,w,h,bd;
  101. bd = 20;
  102. h = w = 80;
  103. x = wid - w;
  104. y = 0;
  105. [lblName setFrame:CGRectMake(x, y, w, h)];
  106. y = self.height - h;
  107. w *= 1.3;
  108. x = wid - w;
  109. [btnScan setFrame:CGRectMake(x, y, w, h)];
  110. [btnScan target:self];
  111. y = 0;
  112. x = bd;
  113. h = 35;
  114. w = kSize.width - bd - w;
  115. [self.textLabel setFrame:CGRectMake(x, y, w, h)];
  116. y += h-10;
  117. [self.detailTextLabel setFrame:CGRectMake(x, y, w, h)];
  118. y += h ;
  119. w = h = 40;
  120. [imgDate setFrame:CGRectMake(x, y, w, h)];
  121. x += w +10;
  122. w = [titNum.text sizeForFont:NormalFont].width ;
  123. [titNum setFrame:CGRectMake(x, y - 5, w, 25)];
  124. [titCount setFrame:CGRectMake(x, y + 20, w, 25)];
  125. x += w +10;
  126. w = 100;
  127. [lblNum setFrame:CGRectMake(x, y - 3, w, 25)];
  128. [countLabel setFrame:CGRectMake(x, y + 20, w, 25)];
  129. x = bd;
  130. y += h ;
  131. w = h = 40;
  132. [imgNum setFrame:CGRectMake(x, y, w, h)];
  133. x += w +10;
  134. w = [titDate.text sizeForFont:NormalFont].width ;
  135. [titDate setFrame:CGRectMake(x, y - 2, w, h)];
  136. x += w +10;
  137. w = 200;
  138. [lblDate setFrame:CGRectMake(x, y - 5, w, h+20)];
  139. // for (UIView* v in self.subviews) {
  140. // SetRandomColor(v);
  141. // }
  142. }
  143. -(void)click:(MyBlockType)block
  144. {
  145. clkBlock = block;
  146. }
  147. -(void)btnClick:(UIButton*)sender
  148. {
  149. if (clkBlock) {
  150. clkBlock(_model);
  151. }
  152. }
  153. -(void)setStyle:(int)style
  154. {
  155. _style = style;
  156. if (1 == style) {
  157. [btnScan setHidden:YES];
  158. }
  159. }
  160. @end
  161. CGFloat PlanCellHeight()
  162. {
  163. return 150;
  164. }