JXSheBeiCell.m 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. //
  2. // JXSheBeiCell.m
  3. // shiku_im
  4. //
  5. // Created by 123 on 2020/5/26.
  6. // Copyright © 2020 Reese. All rights reserved.
  7. //
  8. #import "JXSheBeiCell.h"
  9. @interface JXSheBeiCell ()
  10. @property (nonatomic,weak) UILabel *titleL;
  11. @property (nonatomic,weak) UILabel *subTitle;
  12. @property (nonatomic,weak) UILabel *searitL;
  13. @end
  14. @implementation JXSheBeiCell
  15. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  16. [super setSelected:selected animated:animated];
  17. }
  18. -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  19. if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  20. UILabel *titleL=[[UILabel alloc]init];
  21. titleL.text=@"HUAWEI-AI0-AL00";
  22. titleL.font=[UIFont systemFontOfSize:15 weight:UIFontWeightRegular];
  23. [self.contentView addSubview:titleL];
  24. self.titleL=titleL;
  25. [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
  26. make.top.mas_equalTo(15);
  27. make.left.mas_equalTo(15);
  28. }];
  29. UILabel *subTitle=[[UILabel alloc]init];
  30. subTitle.text=@"20-05-24 03:02:11 ";
  31. subTitle.textColor=kRGBColor151;
  32. subTitle.font=[UIFont systemFontOfSize:15 weight:UIFontWeightRegular];
  33. [self.contentView addSubview:subTitle];
  34. self.subTitle=subTitle;
  35. [subTitle mas_makeConstraints:^(MASConstraintMaker *make) {
  36. make.top.mas_equalTo(15);
  37. make.left.mas_equalTo(titleL.mas_right).mas_offset(11);
  38. }];
  39. UILabel *searitL=[[UILabel alloc]init];
  40. searitL.text=@"20-05-2403:02:11 ";
  41. searitL.textColor=kRGBColor151;
  42. searitL.font=[UIFont systemFontOfSize:15 weight:UIFontWeightRegular];
  43. [self.contentView addSubview:searitL];
  44. self.searitL=searitL;
  45. [searitL mas_makeConstraints:^(MASConstraintMaker *make) {
  46. make.top.mas_equalTo(titleL.mas_bottom).mas_offset(11);
  47. make.left.mas_equalTo(15);
  48. }];
  49. UIButton *rightIMG=[[UIButton alloc]init];
  50. [rightIMG setTitle:@"删除" forState:UIControlStateNormal];
  51. rightIMG.backgroundColor=[UIColor redColor];
  52. rightIMG.titleLabel.font=[UIFont systemFontOfSize:13 weight:UIFontWeightMedium];
  53. rightIMG.layer.cornerRadius=5;
  54. rightIMG.layer.masksToBounds=YES;
  55. [self.contentView addSubview:rightIMG];
  56. [rightIMG addTarget:self action:@selector(deleteBtnClick:) forControlEvents:UIControlEventTouchUpInside];
  57. self.rightIMG=rightIMG;
  58. [rightIMG mas_makeConstraints:^(MASConstraintMaker *make) {
  59. make.centerY.mas_equalTo(self.contentView.mas_centerY);
  60. make.right.mas_equalTo(-10);
  61. make.width.mas_equalTo(49);
  62. make.right.mas_equalTo(30);
  63. }];
  64. }
  65. return self;
  66. }
  67. -(void)deleteBtnClick:(UIButton *)sender{
  68. if (_block) {
  69. _block(sender);
  70. }
  71. }
  72. -(void)setModel:(shebeiModel *)Model{
  73. _Model=Model;
  74. self.titleL.text=[NSString stringWithFormat:@"%@",Model.deviceName];
  75. self.searitL.text=[NSString stringWithFormat:@"%@",Model.deviceIMSI];
  76. NSDateFormatter *matter = [[NSDateFormatter alloc]init];
  77. matter.dateFormat =@"YYYY-MM-dd HH:mm";
  78. NSDate *date = [NSDate dateWithTimeIntervalSince1970:[Model.loginTime intValue]];
  79. NSString*timeStr = [matter stringFromDate:date];
  80. self.subTitle.text=[NSString stringWithFormat:@"%@",timeStr];
  81. }
  82. + (instancetype)cellWithTableView:(UITableView *)tableView
  83. {
  84. static NSString *ID = @"JXSheBeiCell";
  85. JXSheBeiCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
  86. if (!cell) {
  87. cell = [[JXSheBeiCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
  88. cell.selectionStyle=UITableViewCellSelectionStyleNone;
  89. }
  90. return cell;
  91. }
  92. @end