《省钱达人》与《猎豆优选》UI相同版。域名tbk

DRPrivilegeReferralTableViewCell.m 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. //
  2. // DRPrivilegeReferralTableViewCell.m
  3. // YouHuiProject
  4. //
  5. // Created by jcymac on 2018/5/21.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "DRPrivilegeReferralTableViewCell.h"
  9. @interface DRPrivilegeReferralTableViewCell()
  10. @property (strong, nonatomic) UIImageView *leftImgView;
  11. @property (strong, nonatomic) UILabel *rightTitle;
  12. @property (strong, nonatomic) UILabel *rightDesc;
  13. @end
  14. @implementation DRPrivilegeReferralTableViewCell
  15. + (instancetype)cellWithTableView:(UITableView *)tableView {
  16. static NSString *cellID = nil;
  17. cellID = NSStringFromClass([self class]);
  18. DRPrivilegeReferralTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
  19. if (!cell) {
  20. cell = [[DRPrivilegeReferralTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
  21. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  22. }
  23. return cell;
  24. }
  25. - (void)awakeFromNib {
  26. [super awakeFromNib];
  27. // Initialization code
  28. }
  29. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  30. [super setSelected:selected animated:animated];
  31. // Configure the view for the selected state
  32. }
  33. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  34. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  35. if (self) {
  36. [self initUI];
  37. }
  38. return self;
  39. }
  40. - (void)initUI {
  41. [self.contentView addSubview:self.leftImgView];
  42. [self.contentView addSubview:self.rightTitle];
  43. [self.contentView addSubview:self.rightDesc];
  44. [self.leftImgView mas_makeConstraints:^(MASConstraintMaker *make) {
  45. make.left.mas_equalTo(12);
  46. make.width.height.mas_equalTo(25);
  47. make.centerY.mas_equalTo(self.mas_centerY);
  48. }];
  49. [self.rightTitle mas_makeConstraints:^(MASConstraintMaker *make) {
  50. make.bottom.mas_equalTo(self.leftImgView.mas_top).mas_offset(10);
  51. make.left.mas_equalTo(self.leftImgView.mas_right).mas_offset(20);
  52. }];
  53. [self.rightDesc mas_makeConstraints:^(MASConstraintMaker *make) {
  54. make.left.mas_equalTo(self.rightTitle);
  55. make.top.mas_equalTo(self.rightTitle.mas_bottom).mas_offset(5);
  56. make.right.mas_equalTo(-10);
  57. }];
  58. }
  59. -(void)setModel:(DRPrivilegeReferralModel *)model{
  60. _model = model;
  61. [self.leftImgView sd_setImageWithURL:[NSURL URLWithString:model.img]];
  62. self.rightTitle.text = model.title;
  63. self.rightDesc.text = model.content;
  64. }
  65. - (UIImageView *)leftImgView {
  66. if (!_leftImgView) {
  67. _leftImgView = [[UIImageView alloc] init];
  68. _leftImgView.backgroundColor = [UIColor clearColor];
  69. }
  70. return _leftImgView;
  71. }
  72. - (UILabel *)rightTitle {
  73. if (!_rightTitle) {
  74. _rightTitle = [[UILabel alloc] init];
  75. _rightTitle.textColor = [UIColor YHColorWithHex:0x333333];
  76. _rightTitle.font = [UIFont systemFontOfSize:15];
  77. }
  78. return _rightTitle;
  79. }
  80. - (UILabel *)rightDesc {
  81. if (!_rightDesc) {
  82. _rightDesc = [[UILabel alloc] init];
  83. _rightDesc.textColor = [UIColor YHColorWithHex:0x666666];
  84. _rightDesc.font = [UIFont systemFontOfSize:12];
  85. _rightDesc.numberOfLines = 0;
  86. }
  87. return _rightDesc;
  88. }
  89. @end