WD_DetailCell.m 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. //
  2. // WD_DetailCell.m
  3. // LNManager
  4. //
  5. // Created by EchoShacolee on 2017/6/6.
  6. // Copyright © 2017年 lee. All rights reserved.
  7. //
  8. #import "WD_DetailCell.h"
  9. #import "NSString+ex.h"
  10. @interface WD_DetailCell ()
  11. {
  12. UIView * _whiteV;
  13. UILabel * _titleLab;
  14. UILabel * _contentLab;
  15. UILabel * _timeLab;
  16. }
  17. @end
  18. @implementation WD_DetailCell
  19. - (void)awakeFromNib {
  20. [super awakeFromNib];
  21. // Initialization code
  22. }
  23. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  24. [super setSelected:selected animated:animated];
  25. // Configure the view for the selected state
  26. }
  27. +(WD_DetailCell *)cellForTableView:(UITableView *)tableView{
  28. WD_DetailCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellId"];
  29. if (!cell) {
  30. // cell = [[[NSBundle mainBundle]loadNibNamed:@"WD_DetailCell" owner:nil options:nil]lastObject];
  31. cell = [[WD_DetailCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cellId"];
  32. }
  33. return cell;
  34. }
  35. -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  36. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  37. if (self) {
  38. self.contentView.backgroundColor = KBackGroundColor;
  39. _whiteV = [UIView new];
  40. _whiteV.backgroundColor = [UIColor whiteColor];
  41. [self.contentView addSubview:_whiteV];
  42. _titleLab = [[UILabel alloc]init];
  43. _titleLab.font = [UIFont systemFontOfSize:17];
  44. _titleLab.numberOfLines = 0;
  45. [_whiteV addSubview:_titleLab];
  46. _contentLab = [[UILabel alloc]init];
  47. _contentLab.font = [UIFont systemFontOfSize:14];
  48. _contentLab.numberOfLines = 0;
  49. _contentLab.textColor = [UIColor darkGrayColor];
  50. [_whiteV addSubview:_contentLab];
  51. _timeLab = [[UILabel alloc]init];
  52. _timeLab.font = [UIFont systemFontOfSize:13];
  53. _timeLab.textAlignment = NSTextAlignmentCenter;
  54. // _timeLab.backgroundColor = KBackGroundColor;
  55. _timeLab.textColor = [UIColor lightGrayColor];
  56. [self.contentView addSubview:_timeLab];
  57. }
  58. return self;
  59. }
  60. -(void)setDic:(NSDictionary *)dic{
  61. if (_dic != dic) {
  62. _titleLab.text = dic[@"MI_TITLE"];
  63. _contentLab.text = dic[@"MI_CONTENT"];
  64. _timeLab.text = dic[@"MI_CRDATE"];
  65. }
  66. }
  67. -(void)layoutSubviews{
  68. CGFloat wid = self.width;
  69. CGFloat x,y,w,h,bd;
  70. x = 10;
  71. y = 0;
  72. w = wid - 40 - 20;
  73. bd = 5;
  74. h = [_titleLab.text heightForWid:w Font:17];
  75. _titleLab.frame = setDIYFrame;
  76. y += h+bd;
  77. h = [_contentLab.text heightForWid:w Font:14];
  78. _contentLab.frame = setDIYFrame;
  79. h = y+h+bd;
  80. y = 10;
  81. w = wid-20;
  82. _whiteV.frame = setDIYFrame;
  83. y += h+bd;
  84. h = 21;
  85. w = [_timeLab.text sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]}].width+10;
  86. _timeLab.frame = setDIYFrame;
  87. _timeLab.center = CGPointMake(self.center.x, y+h/2);
  88. }
  89. @end