猎豆优选

LDPotentialFansCell.m 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. //
  2. // LDPotentialFansCell.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/7/12.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "LDPotentialFansCell.h"
  9. @interface LDPotentialFansCell ()
  10. @property (nonatomic, strong) UIImageView *iconView;
  11. @property (nonatomic, strong) UILabel *name;
  12. @property (nonatomic, strong) UILabel *date;
  13. @end
  14. @implementation LDPotentialFansCell
  15. - (void)awakeFromNib {
  16. [super awakeFromNib];
  17. // Initialization code
  18. }
  19. + (instancetype)cellWithTableView:(UITableView *)tableView {
  20. static NSString *cellID = nil;
  21. cellID = NSStringFromClass([self class]);
  22. LDPotentialFansCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
  23. if (!cell) {
  24. cell = [[LDPotentialFansCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
  25. }
  26. return cell;
  27. }
  28. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  29. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  30. if (self) {
  31. [self initUI];
  32. }
  33. return self;
  34. }
  35. - (void)initUI {
  36. [self.contentView addSubview:self.iconView];
  37. [self.contentView addSubview:self.name];
  38. [self.contentView addSubview:self.date];
  39. [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
  40. make.left.mas_equalTo(15);
  41. make.width.height.mas_equalTo(50);
  42. make.centerY.mas_equalTo(self.mas_centerY);
  43. }];
  44. [self.name mas_makeConstraints:^(MASConstraintMaker *make) {
  45. make.left.mas_equalTo(self.iconView.mas_right).mas_offset(15);
  46. make.top.mas_equalTo(15);
  47. }];
  48. [self.date mas_makeConstraints:^(MASConstraintMaker *make) {
  49. make.left.mas_equalTo(self.name.mas_left);
  50. make.top.mas_equalTo(self.name.mas_bottom).mas_offset(6);
  51. }];
  52. }
  53. - (void)setModel:(LDPotentialModel *)model {
  54. _model = model;
  55. self.name.text = model.name;
  56. self.date.text = model.create_at;
  57. [self.iconView sd_setImageWithURL:[NSURL URLWithString:model.img] placeholderImage:[UIImage imageNamed:@"login"]];
  58. }
  59. #pragma mark -懒加载
  60. - (UIImageView *)iconView {
  61. if (!_iconView) {
  62. _iconView = [[UIImageView alloc] init];
  63. _iconView.contentMode = UIViewContentModeScaleAspectFill;
  64. _iconView.layer.masksToBounds = YES;
  65. _iconView.backgroundColor = [UIColor yhGrayColor];
  66. [_iconView setImage:[UIImage imageNamed:@"login"]];
  67. _iconView.layer.cornerRadius = 25;
  68. }
  69. return _iconView;
  70. }
  71. - (UILabel *)name {
  72. if (!_name) {
  73. _name = [[UILabel alloc] init];
  74. _name.textColor = [UIColor YHColorWithHex:0x333333];
  75. _name.font = [UIFont systemFontOfSize:14];
  76. _name.text = @"未知用户";
  77. }
  78. return _name;
  79. }
  80. - (UILabel *)date {
  81. if (!_date) {
  82. _date = [[UILabel alloc] init];
  83. _date.textColor = [UIColor YHColorWithHex:0x878787];
  84. _date.font = [UIFont systemFontOfSize:12];
  85. _date.text = @"--";
  86. }
  87. return _date;
  88. }
  89. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  90. [super setSelected:selected animated:animated];
  91. // Configure the view for the selected state
  92. }
  93. @end